|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: GP: Flipping a point across a line: The answer
Hallo, If you implemented the algorithm I suggested above in all 2/3 axes (depending upon what your needs are) you will have noticed that there is no need for any reflection equations whatsoever, it all simply works out because mechanics is cool like that. :0) - Don -----Original Message----- From: Eudoxus3 <Eudoxus@freeuk.com> To: Game programmer <gameprogrammer@gameprogrammer.com> Date: 07 September 1999 12:27 Subject: Re: GP: Flipping a point across a line: The answer >On Mon 06 Sep, Kevin Shea wrote: >> Anyway, sorry to bring this one back up after it seems to have been left >> to lie for a while but I've just read this and think there are a few >> things worth pointing out about the answers given so far. >> Eudoxus3 wrote: >> > // declare variables to use, integers are Ok. >> > declare A, B, C, D, E, Y, M, ZZ, P >> > // so, from here we want to get `D`, which will also have x and y values... >> > // this bit calculates where a line from C to A,B at a right angle will >> > // intersect... >> > Y = (B.y - A.y) / (B.x - A.x) >> The basic algorithm everyone has used is correct, but there are a few >> problems with it - (above) what if B.x == A.x? Especially if you're >> using >> integer display-coords? I saw another mail involving tan(), cos() etc >> which has a related problem - arctan(what?) == 90 degrees? > >The problem was not used to reflect a point exactly. I had two balls >bouncing around, when a collision was detected between them I wanted to do >a small calculation to work out where the next point of the moving ball >(one was actually fixed in place) was. For this I needed to reflect it's >target destination across a line which I perceived as being between the >centre points of the two balls. This was ok as I could guarentee that they >would never be in exactly the same place - if they were there was a problem >with the circle collision detection. > >As it happens, the program is not perfect and the extension for it to >handle lots of moving balls does not work properly (above 2 or 3). >These and lots more demo applets with code can be found on my web site; > http://www.eudoxus.freeuk.com/ >just in case you fancy taking a look and suggesting anything - any help on >the bouncing ball/s would be greatly appreciated. > >Incidentally, I don't want to use SQRT, DIV, MOD, ARC, SIN, COS, TAN at >all, which my program doesn't, because it MUST be as fast as possible. >Then again, it doen't work perfectly, so I'm losing right now! > > >Regards, > >Matt. W. >-- >*** eudoxus@freeuk.com *** http://members.xoom.com/eudoxusM/ > mwebster@apsoft.co.uk > >================================================================= >To SUBSCRIBE or UNSUBSCRIBE please visit >http://gameprogrammer.com/mailinglist.html > > ================================================================= To SUBSCRIBE or UNSUBSCRIBE please visit http://gameprogrammer.com/mailinglist.html
|
|