|
 |
> Suppose you have a line from point A to point B. Compute the vector AB,
> dot product V . A and call it k.
>
> Which side of the line is point X on? Well, take the dot product V . X,
> and subtract k. The result is negative on one side, positive on the other,
> and zero if X is on the line itself (or at least, parallel to it).
>
> ...so basically, it's a ray/plane intersection test, except the "plane" is
> a 2D slide - a line.
Sorry, but that seems much more complicated and using up more instructions
compared to the cross product:
> A = (0,0)
> B = (0,1)
> AB = (0,1) - (0,0) = (0,1) [already unital]
No need to make AB unital for the cross product method (saves a square root
and divide).
> V = (0,1) * {(0,-1), (1,0)} = (-1,0)
> k = (0,0) . (-1,0) = 0
No need to calculate V or k for the cross product method (saves some
multiplies and adds).
> X = (1,0)
> X . V - k = (1,0) . (-1,0) - 0 = -1
X cross AB = (1,0) x (0,1) = (1)(1) - (0)(0) = 1
(saves one subtraction compared to your method)
> Y = (-1,0)
> Y . V - k = (-1,0) . (-1,0) - 0 = +1
Y cross AB = (-1,0) x (0,1) = (-1)(1) - (0)(0) = -1
(saves one subtraction compared to your method)
Post a reply to this message
|
 |