anon
anon

Reputation:

Collinear points

If i have a,b,c point with x,y in form of vectors than how can I find collinear points..

fabs((b.x_-a.x_)*(c.y_-a.y_)-(c.x_-a.x_)*(b.y_-a.y_) its used like this.. how its like this?

Upvotes: 10

Views: 4031

Answers (3)

Keith
Keith

Reputation: 6834

fabs((b.x_-a.x_)*(c.y_-a.y_)-(c.x_-a.x_)*(b.y_-a.y_) is the cross product.

Note that:

fabs(crossProduct( (b-a), (c-a) ) ) == length(b-a)*distance of c from the line (a,b)

Hence is zero if and only if only when c lies on the line (a,b), only providing a,b are distinct.

I'd be interested to hear comments, or better examples, as to why this might be "unstable". I always thought it was quite robust.

Upvotes: 3

brainjam
brainjam

Reputation: 19005

You can interpret the formula as a cross product (as explained in winwaed's answer), or you can interpret it as being about the slopes of the vectors b-a and c-a, as explained in this answer.

Upvotes: 3

winwaed
winwaed

Reputation: 7829

The differences give you the internal vectors from a to b, and a to c.

The multiplications then represent the cross product between these two vectors. The cross product is proportional to the sine of the angle between these two vectors. The sine between these two vectors is zero when the points are collinear.

Your particular formula is a 2d contraction of the more conventional 3d cross product. See: http://en.wikipedia.org/wiki/Cross_product

Upvotes: 6

Related Questions