1. More trouble with sequences

I hate to keep criticising the language structure, but I think that the
sequence operations ought really to go one stage further.

Suppose I have a sequence of co-ordinates

sequence coords
coords={{1,2},{50,20},{40,100}  ... }

I want to scale them

coords=coords*2

or in PP

coords =* 2


I want to scale them from a different origin...

sequence origin
origin={320,240} --middle of screen

coords=(coords-origin)*2+origin

but this does *not* work, I have to do

origin=repeat(origin,length(coords))
coords=(coords-origin)*2+origin

The same also applies if I want to stretch my co-ordinates :
coords=coords*{2,1}  --Stretch factor 2 parallel to x-axis. Not legal code

Presumably there is some reason why this is excluded Rob ?

Daniel

new topic     » topic index » view message » categorize

2. Re: More trouble with sequences

Lmailles wrote:
> I want to scale them from a different origin...
>
> sequence origin
> origin={320,240} --middle of screen
>
> coords=(coords-origin)*2+origin
>
> but this does *not* work, I have to do
>
> origin=repeat(origin,length(coords))
> coords=(coords-origin)*2+origin
>
> The same also applies if I want to stretch my co-ordinates :
> coords=coords*{2,1}  --Stretch factor 2 parallel to x-axis. Not legal code
>
> Presumably there is some reason why this is excluded Rob ?

god damn are you every lazy :)

in pp:

with each point in coords do
    point = (point - origin) * 2 + origin
end with

with each point in coords do
    point = point * {2, 1}
end with

--

 . m i k e   b u r r e l l .
. http://mikpos.home.ml.org .
  .  mikpos at softhome.net  .

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu