math question
Hi List
I have four points [x,y] on a plane and I need to be able to determine if they are in a line at any angle. I
know that they are in line if all of the x values are equal, or if all of the y values are equal. I do not know
what math to use to check otherwise. Is this a vector problem? trig?
Any hints are appreciated.
Thanks
David
Need personalized email and website? Look no further. It’s easy
with Doteasy $0 Web Hosting! Learn more at http://www.doteasy.com
One way you could do this is calculate the normal to the plane
that is created by three points. Pick one point, this will be your
origin. Now pick two points and draw a line from them to your origin,
this
should form a plane. Now take your fourth point and create
a vector from the origin, call this the vector x. Now
you can calcualte the angle between the plane and x,
if it is zero then you know all points are in line on the axis
the plane resides on.
Anthony
—– Original Message —–
From: David Morneau
Date: Wednesday, June 20, 2007 6:46 pm
Subject: [maxmsp] math question
> Hi List
>
> I have four points [x,y] on a plane and I need to be able to
> determine if they are in a line at any angle. I
> know that they are in line if all of the x values are equal, or if
> all of the y values are equal. I do not know
> what math to use to check otherwise. Is this a vector problem? trig?
>
> Any hints are appreciated.
>
> Thanks
> David
>
>
>
> Need personalized email and website? Look no further. It’s easy
> with Doteasy $0 Web Hosting! Learn more at http://www.doteasy.com
>
I may have been a bit vague in my explanation. Take a look
at this… http://www.geocities.com/SiliconValley/2151/math3d.html
Once you have calculated the normal to the plane, I think you
can take the dot product of the normal with your remaining
point(vector), that should give you the angle between the two.
Anthony
—– Original Message —–
From: apalomba@austin.rr.com
Date: Wednesday, June 20, 2007 6:57 pm
Subject: Re: [maxmsp] math question
To: maxmsp@cycling74.com, david@5of4.com
> One way you could do this is calculate the normal to the plane
> that is created by three points. Pick one point, this will be your
> origin. Now pick two points and draw a line from them to your
> origin,
> this
> should form a plane. Now take your fourth point and create
> a vector from the origin, call this the vector x. Now
> you can calcualte the angle between the plane and x,
> if it is zero then you know all points are in line on the axis
> the plane resides on.
>
>
>
>
> Anthony
>
>
> —– Original Message —–
> From: David Morneau
> Date: Wednesday, June 20, 2007 6:46 pm
> Subject: [maxmsp] math question
>
> > Hi List
> >
> > I have four points [x,y] on a plane and I need to be able to
> > determine if they are in a line at any angle. I
> > know that they are in line if all of the x values are equal, or
> if
> > all of the y values are equal. I do not know
> > what math to use to check otherwise. Is this a vector problem? trig?
> >
> > Any hints are appreciated.
> >
> > Thanks
> > David
> >
> >
> >
> > Need personalized email and website? Look no further. It’s easy
> > with Doteasy $0 Web Hosting! Learn more at http://www.doteasy.com
> >
>
You want to look at slopes i.e.
(y1y0)/(x1x0)
if these are the same for all points, then they are colinear.
wes
On 6/20/07, apalomba@austin.rr.com
> I may have been a bit vague in my explanation. Take a look
> at this… http://www.geocities.com/SiliconValley/2151/math3d.html
> Once you have calculated the normal to the plane, I think you
> can take the dot product of the normal with your remaining
> point(vector), that should give you the angle between the two.
>
>
> Anthony
>
>
> —– Original Message —–
> From: apalomba@austin.rr.com
> Date: Wednesday, June 20, 2007 6:57 pm
> Subject: Re: [maxmsp] math question
> To: maxmsp@cycling74.com, david@5of4.com
>
> > One way you could do this is calculate the normal to the plane
> > that is created by three points. Pick one point, this will be your
> > origin. Now pick two points and draw a line from them to your
> > origin,
> > this
> > should form a plane. Now take your fourth point and create
> > a vector from the origin, call this the vector x. Now
> > you can calcualte the angle between the plane and x,
> > if it is zero then you know all points are in line on the axis
> > the plane resides on.
> >
> >
> >
> >
> > Anthony
> >
> >
> > —– Original Message —–
> > From: David Morneau
> > Date: Wednesday, June 20, 2007 6:46 pm
> > Subject: [maxmsp] math question
> >
> > > Hi List
> > >
> > > I have four points [x,y] on a plane and I need to be able to
> > > determine if they are in a line at any angle. I
> > > know that they are in line if all of the x values are equal, or
> > if
> > > all of the y values are equal. I do not know
> > > what math to use to check otherwise. Is this a vector problem? trig?
> > >
> > > Any hints are appreciated.
> > >
> > > Thanks
> > > David
> > >
> > >
> > >
> > > Need personalized email and website? Look no further. It’s easy
> > > with Doteasy $0 Web Hosting! Learn more at http://www.doteasy.com
> > >
> >
>
Take 2 points.
If they are not at the same place, determine the equation of the line they
define (for instance of the form x + a.y + b = 0, the 2 points give you a
system of 2 equations that you solve to find a and b).
Then check if your 3rd and 4th points satisfy the equation.
JF.
> Hi List
>
> I have four points [x,y] on a plane and I need to be able to determine if they
> are in a line at any angle. I
> know that they are in line if all of the x values are equal, or if all of the
> y values are equal. I do not know
> what math to use to check otherwise. Is this a vector problem? trig?
>
> Any hints are appreciated.
>
> Thanks
> David
Check out the CGA FAQ, subject 1.03, http://www.exaflop.org/docs/cgafaq/.
Good old FAQs.
– Paul
P.S. Here’s the text:
Subject 1.03: How do I find intersections of 2 2D line segments?
This problem can be extremely easy or extremely difficult depends on your
applications. If all you want is the intersection point, the following
should work:
Let A,B,C,D be 2space position vectors. Then the directed line segments AB
& CD are given by:
AB=A+r(BA), r in [0,1]
CD=C+s(DC), s in [0,1]
If AB & CD intersect, then
A+r(BA)=C+s(DC), or
Ax+r(BxAx)=Cx+s(DxCx)
Ay+r(ByAy)=Cy+s(DyCy) for some r,s in [0,1]
Solving the above for r and s yields
(AyCy)(DxCx)(AxCx)(DyCy)
r = —————————– (eqn 1)
(BxAx)(DyCy)(ByAy)(DxCx)
(AyCy)(BxAx)(AxCx)(ByAy)
s = —————————– (eqn 2)
(BxAx)(DyCy)(ByAy)(DxCx)
Let P be the position vector of the intersection point, then
P=A+r(BA) or
Px=Ax+r(BxAx)
Py=Ay+r(ByAy)
By examining the values of r & s, you can also determine some other limiting
conditions:
If 0< =r<=1 & 0<=s<=1, intersection exists
r<0 or r>1 or s<0 or s>1 line segments do not intersect

If the denominator in eqn 1 is zero, AB & CD are parallel

If the numerator in eqn 1 is also zero, AB & CD are coincident
If the intersection point of the 2 lines are needed (lines in this context
mean infinite lines) regardless whether the two line segments intersect,
then

If r>1, P is located on extension of AB

If r<0, P is located on extension of BA

If s>1, P is located on extension of CD

If s<0, P is located on extension of DC
Also note that the denominators of eqn 1 & 2 are identical.
References:
[O'Rourke]< http://www.exaflop.org/docs/cgafaq/cga0.html#%5BO%27%20Rourke%5D>pp.
24951
[Gems III] < http://www.exaflop.org/docs/cgafaq/cga0.html#%5BGems%20III%5D>pp.
199202 "Faster Line Segment Intersection,"
On 6/20/07, Wesley Smith
> You want to look at slopes i.e.
>
> (y1y0)/(x1x0)
>
> if these are the same for all points, then they are colinear.
>
> wes
>
> On 6/20/07,
> > I may have been a bit vague in my explanation. Take a look
> > at this… http://www.geocities.com/SiliconValley/2151/math3d.html
> > Once you have calculated the normal to the plane, I think you
> > can take the dot product of the normal with your remaining
> > point(vector), that should give you the angle between the two.
> >
> >
> > Anthony
> >
> >
> > —– Original Message —–
> > From: apalomba@austin.rr.com
> > Date: Wednesday, June 20, 2007 6:57 pm
> > Subject: Re: [maxmsp] math question
> > To: maxmsp@cycling74.com, david@5of4.com
> >
> > > One way you could do this is calculate the normal to the plane
> > > that is created by three points. Pick one point, this will be your
> > > origin. Now pick two points and draw a line from them to your
> > > origin,
> > > this
> > > should form a plane. Now take your fourth point and create
> > > a vector from the origin, call this the vector x. Now
> > > you can calcualte the angle between the plane and x,
> > > if it is zero then you know all points are in line on the axis
> > > the plane resides on.
> > >
> > >
> > >
> > >
> > > Anthony
> > >
> > >
> > > —– Original Message —–
> > > From: David Morneau
> > > Date: Wednesday, June 20, 2007 6:46 pm
> > > Subject: [maxmsp] math question
> > >
> > > > Hi List
> > > >
> > > > I have four points [x,y] on a plane and I need to be able to
> > > > determine if they are in a line at any angle. I
> > > > know that they are in line if all of the x values are equal, or
> > > if
> > > > all of the y values are equal. I do not know
> > > > what math to use to check otherwise. Is this a vector problem? trig?
> > > >
> > > > Any hints are appreciated.
> > > >
> > > > Thanks
> > > > David
> > > >
> > > >
> > > >
> > > > Need personalized email and website? Look no further. It’s easy
> > > > with Doteasy $0 Web Hosting! Learn more at http://www.doteasy.com
> > > >
> > >
> >
>
–
—– (*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#) —–
…or you can use some of the test object from the pmpd library :
http://www.maxobjects.com/?v=libraries&id_library=81
(pmpd.tLine2D, pmpd.tSeg2D, pmpd.tSquare2D… will be your friends)
send it your point position, and the cordinates of the line, segment
or square to test.
Mathieu
Thanks for all of the suggestions. I ended up calculating slopes and comparing, it works great and was
easy to implement.
This whole thing makes me wish I’d paid more attention in my math classes instead of complaining
that I would never need this stuff since I’m in music… oh well.
David
Need personalized email and website? Look no further. It’s easy
with Doteasy $0 Web Hosting! Learn more at http://www.doteasy.com
Forums > MaxMSP