View Single Post
Old 02-14-2013, 07:19 PM   PM User | #10
Kathya
New Coder

 
Join Date: Feb 2013
Posts: 11
Thanks: 5
Thanked 0 Times in 0 Posts
Kathya is an unknown quantity at this point
Quote:
Originally Posted by Airblader View Post
In case you need to be flexible with the orientation of the triangle, but also to just not have to hard-code it, a different approach would be – and I hope this doesn't cause any flashbacks – using math. Define a standard triangle and rotate the coordinates of each point around a certain point (ideally the origin).

The wikipedia article even opens with the rotation matrix for a point in two dimensions, so really all you'd have to do is set up an array of points defining a standard triangle (easy!) and then loop over it to apply the matrix to each point (that's a matrix multiplication). And et voila, your array now consists of points defining a rotated triangle.
I'm really not a programmer. I'm a mathematician so no negative flashbacks for me! Thanks!
Kathya is offline   Reply With Quote