Hi everyone ive been working on creating a data structure which stores the line equation in normal form. So the data in the structure is the normal vector and a floating point c.
Ive been working on a method of creating the line eqution from 2 points
// get normal vector
normal = (v-u).Cross();
normal.Normalize();
// Get y-intercept
c = - (normal * u);
but when I tried to use the dot product with line equation to find out what side a point was on the line ie:
const float dp = normal.x*pos.x + normal.y * pos.y + c
[source]
the just didn''t seem to work. Ive tried another method of generating the data:
[source]
normal.x = (v.y-u.y) / (v.x-u.x);
normal.y = -1;
c = u.y - (u.x*normal.x);
this seems to work, but id prefer to use the vector form of the equation. Could you please tell what the problem is. Below is the code for the dot product and cross product which is used in the orginial source:
point2 Cross()
{
return point2(-x,y);
}
inline float operator*(point2& a,point2& b)
{
return a.x*b.x + a.y*b.y;
}
I know this is a very long post. I will be grateful to anyone who can solve this problem. Thanx in advance
Iain Fraser