Hello Chris,
What I would do is:
a. get the center of the quad by averaging the x coordinates and then averaging
the y coordinates
b. once you have that, get the vector (2-dimensional, not to be confused with the built in vector
object) from the center to each point by subtracting the center from each point
d. rotate each vector and add it to the center
Code follows (it belongs in a parent script or a behavior, or else the "me" parameters need to be
removed; watch for wrapped line in rotateVector handler):
on rotateQuad me, initialQuad, anAngle
--anAngle is in degrees
centerPoint = (initialQuad[1] + initialQuad[2] + initialQuad[3] +
initialQuad[4]) / 4.0
rotatedQuad = list()
repeat with i = 1 to 4
rotatedQuad.add(centerPoint+ me.rotateVector(initialQuad[i] -
stationaryPoint, anAngle))
end repeat
return rotatedQuad
end rotateQuad
on rotateVector me, aVector, degrees
return me.makeVector(sqrt(aVector[ 1] * aVector[ 1] + aVector[ 2] * aVector[ 2]),
me.vectorDegrees(aVector) + degrees) --magnitude unrolled
end rotateVector
on makeVector me, magnitude, degrees
theta = degrees * pi / 180.0 --to radians
return point(magnitude * cos(theta), magnitude * sin(theta))
end makeVector
on vectorDegrees me, aVector
--returns degrees from vector (1,0) to aVector (counterclockwise is positive)
return 180.0 + 180.0 * aTan(aVector[1], aVector[2]) / pi
end vectorDegrees
[EMAIL PROTECTED] wrote:
Hi,
How do you rotate a quad (which is already at some specific location) around
it’s centre? I guess you would to it using a matrix transformation, but I’m a
dufus when it comes to math...
Thanks,
Chris.
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]
--
Daniel Nelson
Blue Jade Creative Enterprises LLC
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/lingo-l.cgi To post messages to the list, email
[email protected] (Problems, email [EMAIL PROTECTED]). Lingo-L is for
learning and helping with programming Lingo. Thanks!]