Advertisement

2D Normal

Started by June 24, 2003 01:44 AM
5 comments, last by free lancer 21 years, 8 months ago
How do I find the normal of a 2D line? EDIT: please? [edited by - free lancer on June 24, 2003 3:24:09 AM]
Do you want a slope of perpendicular line, normal vector, or normalized normal vector? How about all of them?

slope of line perpendicular to line with slope m: -1/m
vector with "slope" m: (k, m*k) where k is any real number != 0
normalized vector with "slope" m: (1/p, m/p) where p = sqrt(1 + m*m)

hope that helped.

[edited by - vanillacoke on June 24, 2003 3:30:28 AM]
You know what I never noticed before?
Advertisement
Cheers mate
m is the gradient, right?
I''m not sure, I''ve never really seen that term before with reference to a line... it is dy/dx, which is the gradient of the function of the line, I guess...
You know what I never noticed before?
the normal of a line is just the direction vector of that line, with x and y swapped, and the sign of either the x or y inversed

so:
normal = line.end - line.start;
float temp = normal.x;
normal.x = -normal.y;
normal.y = temp;
normal.Normalize();

My Site

[edited by - Quasar3D on June 24, 2003 6:23:14 AM]
Interesting similarity: the normal of a plane of equation
Ax + By + Cz + D = 0
is (A, B, C)

and the normal of a 2D line of equation
Ax + By + C = 0
is (A, B)

That''s an easy way of remembering it. It also allows you to find the normal of an hyperplane, if you ever needed that

Cédric
Advertisement
That''s cool.
You know what I never noticed before?

This topic is closed to new replies.

Advertisement