[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How to do this?

Casimir

8/13/2008 5:39:00 PM

Dear sirs,

I am planning a simple geometry generation library. XYZ points, primitive
geometry such as triangles and guides that can generate more geometry.

I feel somehow retarted, as usual, so I hope to hear some wise words of
advice.

So, suppose I would want to use the following syntax to command the
little XYZ -points into geometric arrangements of beauty and elegance,
especially the 'along' -bit, where starcircle is defined:

#generates a star by combining two triangles
astar = Guide.polygon((Symbol.triangle(99) + Symbol.triangle(99).rotate
(180))

#generates a circle with stars replacing the points on the circumference
n_int = 20
radius_int = 500
starcircle = Symbol.with_polygon(astar.polygon).along(Symbol.circle
(n_int, radius_int)))
Pic = starcircle.render("svg")
#etc ...

1. How would one manage the generation of starcircle? Store the star
("astar") passed as argument in with_polygon in a Guide-instance and
refer to it once "along"-method is called.

Am I doing this wrong? Is this just artistic nonsens? Should it read, in
a boring CS major style:
starcircle = Symbol.generate_with_guide(astar, Symbol.circle)


2. How to achieve the '+' operation for symbols? For example symbol4 +
somesymbol would join the geometry of the latter into the former. Or
perhaps return a new symbol with combined geometry. How is that handled
for adding number-objects?

I am hoping to achieve as flexible and robust syntax as possible, suited
for adventurous artist types who might try things your average engineer
would think were "wrong".
10 Answers

Daniel Choi

8/13/2008 6:24:00 PM

0


> 2. How to achieve the '+' operation for symbols? For example symbol4 +
> somesymbol would join the geometry of the latter into the former. Or
> perhaps return a new symbol with combined geometry. How is that handled
> for adding number-objects?

This doesn't completely answer your question, but you can define a +
(value) method on any class. You can write any logic you want in it.

E.g.

class TestPlus
def initialize(value=0)
@value = value
end

def +(value)
# replace this with any logic you want. +value+ can be any sort of
object, not just a number
@value += value
puts @value
end
end

x = TestPlus.new(0)
x + 2
=> 2

Adam Shelly

8/13/2008 6:35:00 PM

0

On 8/13/08, Casimir <pikseli@nouuwelspamho.com> wrote:
> Dear sirs,
>
> I am planning a simple geometry generation library. XYZ points, primitive
> geometry such as triangles and guides that can generate more geometry.

I'll offer my opinions in reverse order:

> 2. How to achieve the '+' operation for symbols? For example symbol4 +
> somesymbol would join the geometry of the latter into the former. Or
> perhaps return a new symbol with combined geometry. How is that handled
> for adding number-objects?
>
Most (maybe even all) built-in + operators return a new object, so I'd
do the same for your Symbols. Assuming a Symbol is just a collection
of primitives (lines and points), then it should probably be something
like:

class Symbol
def initialize prims=[]
@primitives = prims
end
def + other
Symbol.new(@primitives +other.primitives )
end
end

> So, suppose I would want to use the following syntax ...
>
> starcircle = Symbol.with_polygon(astar.polygon).along(Symbol.circle
(n_int, radius_int)))
>
> 1. How would one manage the generation of starcircle? Store the star
> ("astar") passed as argument in with_polygon in a Guide-instance and
> refer to it once "along"-method is called.

That could work, but is awkward. What happens if you call #along
without #with first? What if you call #with twice?

> Am I doing this wrong? Is this just artistic nonsens? Should it read, in
> a boring CS major style:
> starcircle = Symbol.generate_with_guide(astar, Symbol.circle)

How about a more ruby style:
tri =Symbol.triangle(side)
astar = tri + tri.rotate(180)
circle = Symbol.circle(pts,radius)
starcircle = circle.map_points{|point| astar.at(point).primitives }

where Symbol#at creates a new instance of itself centered on point, and
Symbol#map_points creates a new symbol based on the block results:

def map_points &block
new_primitives = []
@points.each{|pt| new_primitives<< block.call(pt)}
Symbol.new(newpoints)
end



-Adam

Casimir

8/14/2008 1:44:00 PM

0

Adam Shelly kirjoitti:
> On 8/13/08, Casimir <pikseli@nouuwelspamho.com> wrote:
>> Dear sirs,
>>
>> I am planning a simple geometry generation library. XYZ points, primitive
>> geometry such as triangles and guides that can generate more geometry.
>
> I'll offer my opinions in reverse order:
>
Thank you Daniel Choi and Adam Shelly. I will now build the simple
geometry classes and return here on this topic with some code once I
have implemented the Symbol and Guide classes.

Casimir Pohjanraito

Eddie Haskell

8/3/2012 2:35:00 PM

0


"wy" <wy_@myself.com> wrote in message
news:b427d15f-8711-4b16-89f9-ec2a41a44f50@l30g2000vbj.googlegroups.com...
On Aug 3, 1:22 am, AlleyCat <al...@aohell.com> wrote:
> In article <b6vl18h09h1316hf3211h3jla765818...@4ax.com>,
> trdell1234NOMORES...@gmail.com says...
>
>
>
> > Dems reject GOP move to force layoff notices
>
> Doesn't matter now. The Repugnants put "it" out there for the public to
> know how the Democraps would react... smart move.

> It'll be a forgotten story in no time, if it's even registered at all
> with the public.

Oh, we already know that the Goebbels MSM which is no more than a corrupt
arm of the DNC will only tell people what they want them to know, and if
Hussein was caught fucking a moose they'd go to work ignoring it while
pretending that Romney fucked a wild bore.

"You didn't build that," and "the private sector's doing fine" = invented
Romney gaffs on his foreign trip as a diversion.

-Eddie Haskell


Yoorghis

8/3/2012 3:50:00 PM

0

On Fri, 3 Aug 2012 00:22:33 -0500, AlleyCat <alley@aohell.com> wrote:

>In article <b6vl18h09h1316hf3211h3jla765818ko1@4ax.com>,
>trdell1234NOMORESPAM@gmail.com says...
>>
>> Dems reject GOP move to force layoff notices
>>
>
>Doesn't matter now. The Repugnants put "it" out there for the public to
>know how the Democraps would react... smart move.

Wanna tell us what amendment was included in that legislation?

AlleyCat

8/3/2012 7:49:00 PM

0

In article <nosn189vi5vt29ck1b1a8qgsv5lgcps6r1@4ax.com>,
Yoorghis@Jurgis.net says...
>
> On Fri, 3 Aug 2012 00:22:33 -0500, AlleyCat <alley@aohell.com> wrote:
>
> >In article <b6vl18h09h1316hf3211h3jla765818ko1@4ax.com>,
> >trdell1234NOMORESPAM@gmail.com says...
> >>
> >> Dems reject GOP move to force layoff notices
> >>
> >
> >Doesn't matter now. The Repugnants put "it" out there for the public to
> >know how the Democraps would react... smart move.
>
> Wanna tell us what amendment was included in that legislation?

You posted to the wrong thread again. Please wipe the semen out of your
eyes so you can read better.

Beaker

8/3/2012 10:32:00 PM

0

AlleyCat wrote:
>
> In article <b6vl18h09h1316hf3211h3jla765818ko1@4ax.com>,
> trdell1234NOMORESPAM@gmail.com says...
> >
> > Dems reject GOP move to force layoff notices
> >
>
> Doesn't matter now. The Repugnants put "it" out there for the public to
> know how the Democraps would react... smart move.

Smart? How? All it does is show how insensitive the republicraps are.

First.Post

8/4/2012 12:27:00 AM

0

On Fri, 03 Aug 2012 16:31:34 -0600, Beaker <mup@pet.com> wrote:

>AlleyCat wrote:
>>
>> In article <b6vl18h09h1316hf3211h3jla765818ko1@4ax.com>,
>> trdell1234NOMORESPAM@gmail.com says...
>> >
>> > Dems reject GOP move to force layoff notices
>> >
>>
>> Doesn't matter now. The Repugnants put "it" out there for the public to
>> know how the Democraps would react... smart move.
>
>Smart? How? All it does is show how insensitive the republicraps are.

Insensitive? To want to give people fair warning that they may be
getting laid off a couple months in advance as opposed to not giving
them any warning at all and letting ALL of them sit and worry through
the entiore holiday season about their jobs is insensitive?
Years ago as a union electrical apprentice I used to appreciate the
"scheduled layoffs" that we were given at least two weeks warning of a
hell of a lot more than the "show up for work and discover you just
got laid off" method.
If you read the original article posted then you would read where the
democrats are championing giving no advance warning whatsoever.
"The provision would have overturned Labor Department guidance this
week to federal contractors that they do not have to warn their
employees about potential layoffs from the automatic, across-the-board
cuts that kick in Jan. 2."

Funny. The party that is supposed to be all about "the worker"
advising contractors to pretty much shit on the worker.

Eddie Haskell

8/6/2012 6:54:00 PM

0


"Beaker" <mup@pet.com> wrote in message news:501C5146.FCEFFB20@pet.com...
> AlleyCat wrote:
>>
>> In article <b6vl18h09h1316hf3211h3jla765818ko1@4ax.com>,
>> trdell1234NOMORESPAM@gmail.com says...
>> >
>> > Dems reject GOP move to force layoff notices
>> >
>>
>> Doesn't matter now. The Repugnants put "it" out there for the public to
>> know how the Democraps would react... smart move.
>
> Smart? How? All it does is show how insensitive the republicraps are.

We issue the notices while you do the firing?

Deranged lying fuck.

<shoots bird>

-Eddie Haskell


Obama-not

8/6/2012 7:01:00 PM

0


__________________________________________________________________________

....October campaign surprise coming as Obama struggles to find traction.
__________________________________________________________________________

http://app1.kuhf.org/articles/1343404602-Construction-A-Go-For-Southern-Leg-Of-Keysto...

Construction A Go For Southern Leg Of Keystone XL

July 27, 2012

by: Andrew Schneider

President Barack Obama encouraged TransCanada to pursue the Gulf Coast
project after he rejected the broader Keystone XL plan, saying it needed
to be rerouted around Nebraska?s environmentally sensitive Sandhills
region. For that project, the company needs presidential approval
because it crosses an international border. The shorter portion only
requires permits from state and federal agencies.

The company is working with Nebraska?s Department of Environmental
Quality to map an alternate route

___________________________________________________________________________

...."working with"...or done and in the bag waiting for Obama's October
surprise?
___________________________________________________________________________

http://business.financialpost.com/2012/05/04/transcanada-applies-for-keystone-xl-pipeline-permit/?__ls...

TransCanada takes another crack at Keystone XL pipeline with new route

Sheldon Alberts, Postmedia News | May 4, 2012

WASHINGTON ? TransCanada Corp. on Friday reapplied to the U.S. State
Department for a presidential permit to build the controversial Keystone
XL oilsands pipeline, immediately triggering a new fight with opponents
over the scope of a coming environmental impact study into the project.

In an interview with Postmedia News, TransCanada executive Alex Pourbaix
said the Calgary-based company expects the Obama administration?s review
of Keystone XL to be limited to the new rerouted portion of the pipeline
through Nebraska.

TransCanada submitted its new application for a presidential permit just
two weeks after it proposed several new routes for Keystone XL that
avoid the ecologically fragile Sand Hills region of Nebraska.

President Barack Obama denied TransCanada?s original permit application
in January, citing his administration?s concerns about the impact
construction would have on the delicate topsoil in the Sand Hills region
and the potential for pollution of the vast Ogallala Aquifer that
underlies the area.

____________________________________________________________________________

Obama will launch this one as a play for union votes and a try at
neutralizing Romney's pro-jobs and domestic energy policies.

Folks, this is what his cavalier use of the Executive Order is all about
- cheap campaign shell games for a work already in progress, and a deal
obviously made months ago!

TCP would never build the southern leg is the northern feeder were not
to be approved.
______________________________________________________________________________