Results 1 to 2 of 2

Math Help - Rhombus inside Rectangle : testing coordinates

  1. #1
    Newbie
    Joined
    Oct 2008
    Posts
    1

    Rhombus inside Rectangle : testing coordinates

    Hi, I am building a web game, and I came across a small issue you might help me with:

    I have a rhombus inside a rectangle, and some random coordinates inside the rectangle. I have to test if these coordinates are inside the rhombus or outside of it. That’s it!

    I know everything about the rectangle and rhombus (angles & length)
    I could devise an ugly switch case to determine this, but I was wondering if they’re wasn’t a better (and faster ) approach to this problem.
    Attached Thumbnails Attached Thumbnails Rhombus inside Rectangle : testing coordinates-rombo.gif  
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member pankaj's Avatar
    Joined
    Jul 2008
    From
    New Delhi(India)
    Posts
    317
    Consider centre of the rectangle as origin and let the diagonals of the rhombus lie along the x-axis and the y-axis.The coordinates of the vertices of the rhombus are A(\frac{-d}{2},0),D(0,\frac{-D}{2}),C(\frac{d}{2},0), B(0,\frac{D}{2}).

    The cartesian equations of the sides AD,DC,CB, BA are respectively

    \frac{X}{\frac{-d}{2}}+\frac{Y}{\frac{-D}{2}}-1=0

    \frac{X}{\frac{d}{2}}+\frac{Y}{\frac{-D}{2}}-1=0

    \frac{X}{\frac{d}{2}}+\frac{Y}{\frac{D}{2}}-1=0

    \frac{X}{\frac{-d}{2}}+\frac{Y}{\frac{D}{2}}-1=0


    When we substitute (0,0) in the LHS of the above equations we get -1 i.e. a negative quantity is obtained in all the four cases.Therefore all points inside the rhombus when substituted in the LHS of the above equations must yield a negative quantity.

    Hope this helps.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Rectangle and Rhombus
    Posted in the Algebra Forum
    Replies: 3
    Last Post: October 8th 2011, 09:02 AM
  2. Replies: 2
    Last Post: June 25th 2011, 12:21 PM
  3. Replies: 6
    Last Post: June 2nd 2011, 04:56 PM
  4. Replies: 3
    Last Post: November 8th 2010, 06:16 PM
  5. Rhombus - Rectangle
    Posted in the Geometry Forum
    Replies: 1
    Last Post: October 31st 2010, 04:40 PM

Search Tags


/mathhelpforum @mathhelpforum