Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 02 January 2006 - 05:08 PM
Posted 02 January 2006 - 05:14 PM
0 1
[x y] * = [Xn Yn]
-1 0
[Xt Yt] = [x2 y2]-[x1 y1] = [x2-x1 y2-y1]
0 1
[Xn Yn] = [x2-x1 y2-y1] * = [x1-x2 y2-y1]
-1 0
Posted 02 January 2006 - 05:33 PM
Posted 02 January 2006 - 06:01 PM
Quote:
Original post by hplus0603
0 1
[Xn Yn] = [x2-x1 y2-y1] * = [x1-x2 y2-y1]
-1 0
Clockwise would be
0 1
[Xn Yn] = [x2-x1 y2-y1] * = [y1-y2 x2-x1]
-1 0
0 -1
[Xn Yn] = [x2-x1 y2-y1] * = [y2-y1 x1-x2]
1 0
Posted 02 January 2006 - 06:02 PM
Posted 02 January 2006 - 07:18 PM
Posted 22 January 2012 - 01:42 AM
Careful with this approach, as you need to handle the case when y1-y2 is zero.So you have two solutiond for m'
m' = -dx/dy
so m' = x1-x2/y2-y1 (1)
or m' = dx/-dy
so m' = x2-x1/y1-y2 (2)
Which are the solutions HPPlus presented
Not everyone working with 2D space has a 3D math library readily available. Hplus' approach makes the most sense (with an thorough explanation even!) and avoids 6 multiplications, 3 subtractions, and storage overhead for z component and the extra vector.Much easier way:
1) Find the direction of the line by subtracting one point from the other
2) Convert the direction into a 3D vector, leave z as 0.
3) do a cross product with (0,0,1)
4) normalize the result
Voila, you have the normal to the line!
Posted 22 January 2012 - 11:07 AM
Not everyone working with 2D space has a 3D math library readily available. Hplus' approach makes the most sense (with an thorough explanation even!) and avoids 6 multiplications, 3 subtractions, and storage overhead for z component and the extra vector.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.