Re: geometric problem
- Posted by Grape Vine <chat_town at HOTMAIL.COM> Mar 18, 1999
- 505 views
Get a book called "Fundamentals of Interavtive Computer Graphics" by J.D. Foley & A. Van Dam ... It has all the math and some good short -cuts in it... Its not a quick read but very helpfull ... It also has a reference to other books and papers(some are able to be found on the net.. the urls excape me right now).... GV >From: Nick <metcalfn at ALPHALINK.COM.AU> >Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU> >To: EUPHORIA at LISTSERV.MUOHIO.EDU >Subject: geometric problem >Date: Fri, 19 Mar 1999 03:30:59 +1000 > >Hi all. I have a small problem which has evaded every attempt I have >made to solve it. I need a routine that does the folowing: > >* Given an arbitrary rectangular polygon {V1, V2, V3, V4} where Vx is >a vertex point {x, y} and the vertexes are ordered clockwise on the >rectangle starting at the top left, so that the line V1 -> V2 might be >called the top, >* Also given a point {x, y} that could be inside or outside the polygon > >* Evaluates two expressions mag_x and mag_y such that both expressions >will be linearly interpolated between opposing lines on the polygon >(left side and right side for mag_x and top to bottom for mag_y) to >provide a value in the range of 0 to 1 while the point is inside the >polygon on either 'axis', and < 0 or > 1 when it is outside. > >Phew! Basically I want to project a point in an arbitrary polygon into >a cartesian space that is the equivalent of a unit square, keeping track >of orientation. This is the reverse of a procedure I use to map such a >coordinate system into an arbitrary polygon. That was easy. Now I need >it back! > >I have had so little success coming up with capable code that i decided >to ask better minds than mine. I have tried seriously twice, enough >times to realize I don't really know whats going on. My first attempt >tried to weight vectors orthagonal to opposing sides (dont laugh) and >was a complete failure. My second attempt found the intercept between >opposing lines, and their angles, then found the angle of a line >connecting the point to the intercept and then evaluated the mag by >comparing the angles. This procedure had more success, but needed to >deal with so many 'special cases', i.e. paralell, and worse, near >paralell lines, angle quadrant problems, etc. that I eventually gave up >on it in despair. I really need something that can handle any weird >input. > >I'm sure there is a simple solution, some kind of simultaneous equation, >but I slept through that class at school (doh!) Please would somebody >with more math than me help me out please. Um, if I havent explained >this very well and you need more information don't hesitate to mail me. > >Thanks, >Nick > Get Your Private, Free Email at http://www.hotmail.com