I firstly apologise the title comes across as vague; I wasn't sure how to condense this issue into a title properly.
I'm working on a system whereby the player fires a projectile at a wall, which then bounces off said wall just as light is reflected (angle of reflectance = angle of incidence).
I appreciate this is as much a mathematical-based question as it is Lua-based, but as the two intertwine so often I presumed this will be acceptable.
This is a concept question as I've been drawing equations and diagrams over this for over an hour now to little deliverance, so I could really do with someone pointing me in the right direction, so to speak.
This Gyazo image shows a recreation of the system I'm trying to achieve.
The projectile may be fired at the wall from any direction, so in any case the script will need to pinpoint where the projectile was fired from and calculate the angle of incidence, i. The script will then need to take i and mirror it along the wall's normal to get the angle of reflectance, r. Once we have r, I can do the rest (whereby a new projectile is created and sent in the direction r degrees from the wall's normal).
In short, I am having trouble calculating the angle of incidence when the projectile is fired from any point in 3D space at the wall, then mirroring that angle along the normal to get the angle of reflectance.
I repeat, I understand ScriptingHelpers is not a request site, but in accordance with the 'How to Post Good Questions and Answers' article, I post this question looking for a pointer in the right direction.
I'm happy to provide more information about what I'm trying to achieve if necessary.
An alternative to the link theCjarmy7 posted is this: http://wiki.roblox.com/index.php?title=Dot_product#Case_study:_Reflecting_lasers