How to Mirror/Reflect a vector against another Vec
BlitzMax Forums/BlitzMax Programming/How to Mirror/Reflect a vector against another Vec
| ||
I just can't do this. Somehow I'm attacking the problem from the wrong angle.. I need to make a vector reflect in a surface, or in other words mirror it in the surface normal. ' M I R R O R ' This was a formula a found, but apperantly it doesn't work Method Mirror( Surface:Vector2D ) 'X = Surface.X* Surface.DOT( Self ) - X 'Y = Surface.Y* Surface.DOT( Self ) - Y EndMethod The example below requires Vector2D.bmx, which you can get here |
| ||
Linkage. |
| ||
if this is what you wanted it to look like: try this: Method Mirror(normal:vector2d) Local dotprod#=-x*normal.x-y*normal.y x=x+2*normal.x*dotprod y=y+2*normal.y*dotprod End Method EDIT: or the above :P |
| ||
Diablo, THANKS!! It all works now! YES! Check this out! Requires: Vector2D.bmx (See my first post above) |