Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a list of points {{4,5},{6,7},{9,8},...} in two-dimensions. I'd like to rotate these points some number of degrees $\theta$ around an arbitrary anchor point in a two-dimensional plane, and recover the transformed point list. Is there a straightforward way to do this? How about for three-dimensional rotations around an arbitrary point?

share|improve this question
    
Have you checked the documentation center? is is very very easy to find in documentation and this question shows no research effort :/ –  Kuba Sep 8 '13 at 15:04
    
@Kuba I've looked at Rotate, GeometricTransform, etc. but they all seem to apply to rotating graphical objects as opposed to point sets. –  ZWei Sep 8 '13 at 15:08
    
If type in "rotation" the second result is RotationTransform. It is always good idea to check related links at the bottom of each documentation page because RotationTranform appears for example in Rotate page. –  Kuba Sep 8 '13 at 15:12
    
@Kuba Is it necessary for me to manually enter in and multiply each point by the appropriate rotation matrix? Shouldn't there be a function that takes the point set, a rotation anchor, and then some rotation parameter? I can't seem to find it. –  ZWei Sep 8 '13 at 15:13
    
RotationTransform[angle \[Degree], anchor] /@ set –  Kuba Sep 8 '13 at 15:15

1 Answer 1

up vote 4 down vote accepted

I think RotationTransform is what you are looking for.

data = {{4, 5}, {6, 7}, {9, 8}};
r[angle_?NumericQ, pivot:{_?NumericQ, _?NumericQ}] = RotationTransform[angle Degree, pivot];
r[45, {1, 1}] /@ data // N
{{0.292893, 5.94975}, {0.292893, 8.77817}, {1.70711, 11.6066}}
share|improve this answer
    
Thanks. For the purposes of my understanding, what is the purpose of angle?NumericQ? –  ZWei Sep 8 '13 at 15:15
    
@Kuba. Thanks for pointing out the typos. I have corrected them. –  m_goldberg Sep 8 '13 at 15:28
1  
@ZWei angle_?NumericQ is a pattern test which will run the function only if you pass Numeric variable for the first argumen –  Kuba Sep 8 '13 at 15:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.