Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP/DBC] vector reflection example

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Jan 2008 04:46
No tag specified because it's technically for both Pro and Classic.
I made this while working on a new tutorial and suddenly forgot how to do reflection. Just move the mouse around to see how a line is reflected off.




TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 27th Jan 2008 07:18
Altered topic title to prevent deletion by mod as it does state it works for both DBC and DBP in the message body.

It now matches all the other snippets which work with both.

TDK_Man

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 29th Jan 2008 21:24
It needs a very slight modification to run in DBC

The green line runs straight through the only dead pixel on my screen

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 17th Feb 2008 03:42
I need to make a correction in the reflection equation.

a = a - 2*(a*n)*n

(a*n) is really suppose to be a dot product b. Here's the new code.



I didn't catch the bug right away because it doesn't present itself when the reflective surface is axis-aligned, as in what demo used.


Login to post a reply

Server time is: 2024-05-17 05:15:24
Your offset time is: 2024-05-17 05:15:24