[PD] rotating coordinate system
Frank Barknecht
fbar at footils.org
Tue Jul 7 18:44:32 CEST 2009
Hallo,
Achim Bornhoeft hat gesagt: // Achim Bornhoeft wrote:
> I need to solve the following problem for different setups of room
> distributions.
>
> Given are x and y values between 0 and 100:
>
> 0/100 100/100
> |
> | x
> |
> | x
> |____________
> 0/0 100/0
>
> I would like to transform the same values mathematically in a way that
> the result correspond to the coordinate system rotated 45 degrees
> clockwise:
>
> 0/0---------0/100
> |
> | x
> |
> | x
> |
> 100/0 100/100
Isn't this a rotation by 90 degrees shown here? :)
Anyway rotating a point is easier if you convert the coordinates to polar
coordinates (radius and angle) first, then add the rotation angle to the
current angle and convert back.
You could do the math yourself, but in Zexy there are some handy abstractions
that do it for you: [cart2pol], [pol2cart] convert between cartesian (x,y) and
polar (r, phi) coordinates:
x y
| |
[cart2pol]
| |
| [+ 0.785398] add rotation angle: 0.785398 is 45 degrees converted to rad
| |
[pol2cart]
| |
x' y'
The phi-angles are specified in rad, not in degrees. If you want to use degree
for the rotation angle, the [deg2rad] object is helpful and it's also part of
zexy. Or make your own: rad=deg*pi/180
Ciao
--
Frank
More information about the Pd-list
mailing list