math question


    Jun 20 2007 | 11:44 pm
    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 www.doteasy.com

    • Jun 20 2007 | 11:55 pm
      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 www.doteasy.com
      >
    • Jun 21 2007 | 12:26 am
      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 www.doteasy.com
      > >
      >
    • Jun 21 2007 | 12:41 am
      You want to look at slopes i.e.
      (y1-y0)/(x1-x0)
      if these are the same for all points, then they are colinear.
      wes
      On 6/20/07, apalomba@austin.rr.com wrote:
      > 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 www.doteasy.com
      > > >
      > >
      >
    • Jun 21 2007 | 12:39 pm
      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
    • Jun 21 2007 | 12:42 pm
      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 2-space position vectors. Then the directed line segments AB
      & CD are given by:
      AB=A+r(B-A), r in [0,1]
      CD=C+s(D-C), s in [0,1]
      If AB & CD intersect, then
      A+r(B-A)=C+s(D-C), or
      Ax+r(Bx-Ax)=Cx+s(Dx-Cx)
      Ay+r(By-Ay)=Cy+s(Dy-Cy) for some r,s in [0,1]
      Solving the above for r and s yields
      (Ay-Cy)(Dx-Cx)-(Ax-Cx)(Dy-Cy)
      r = ----------------------------- (eqn 1)
      (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
      (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay)
      s = ----------------------------- (eqn 2)
      (Bx-Ax)(Dy-Cy)-(By-Ay)(Dx-Cx)
      Let P be the position vector of the intersection point, then
      P=A+r(B-A) or
      Px=Ax+r(Bx-Ax)
      Py=Ay+r(By-Ay)
      By examining the values of r & s, you can also determine some other limiting
      conditions:
      If 0 r1 or s1 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 -
      If s>1, P is located on extension of CD
      -
      If s
      Also note that the denominators of eqn 1 & 2 are identical.
      References:
      [O'Rourke]pp.
      249-51
      [Gems III] pp.
      199-202 "Faster Line Segment Intersection,"
      On 6/20/07, Wesley Smith wrote:
      > You want to look at slopes i.e.
      >
      > (y1-y0)/(x1-x0)
      >
      > if these are the same for all points, then they are colinear.
      >
      > wes
      >
      > On 6/20/07, apalomba@austin.rr.com wrote:
      > > 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 www.doteasy.com
      > > > >
      > > >
      > >
      >
      --
      ----- |(*,+,#,=)(#,=,*,+)(=,#,+,*)(+,*,=,#)| -----
    • Jun 21 2007 | 1:44 pm
      ...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
      www.maxobjects.com
    • Jun 21 2007 | 1:59 pm
      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 www.doteasy.com