We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all!
I have a little square I want to rotate and position it inside a bigger square. I then want to connect verticies from the bigger square to the smaller one. I don't know how to get the position of the rotated vertices.
I found this article: http://math.stackexchange.com/questions/270194/how-to-find-the-vertices-angle-after-rotation
I will try this, but wondered if processing had any built in geometry methods to make it easier.
Thanks in advance.
Dave
Answers
Processing already has all the trigonometry methods built in. Check the trigonometry section in the reference.
However, there are ways to do this more easily by using the transformation matrix.
Thanks for the reply - do you have any examples of using the transformation matrix?
Use screenX() and screenY().
I'm getting close, but not quite there. Here is my example. I want the small circle centered on the rotated upper left vertex of the small square.
Please format your code.
Press the gear icon to edit your post.
Select your code and press ctrl + o.
Leave a line above and below.
I told you to check out screenX and screenY.
But I don't understand, if that's all you need draw the circle before popMatrix after rotate and the circle should be cantered at the coordinates as though rotate never occurred.
I am just using the circle as an indicator in this test code of where i want to calculate. Ultimately, I will be animating the rotation of the small square and I want to connect its vertices to the larger square with lines as it rotates around. I know the point from the large square where the line will originate, but I need the point on the small square where the line will end.
I tried to use ScreenX and ScreenY, but I guess I am not clear on the inputs. In my nested pushMatrix, if I called ScreenX(0,0,0), it still returned 0,0 in world space
changing line 45 to line(0, 0, x1, y1) is what I am looking for (with x1,y1 at the correct vertex);
No really, use screenX() and screenY().
Thank you!
That's what I was talking about.
Read the screenX and screenY reference.