samedi 17 février 2018

C++ SFML How to calculate the normal vector?

I'm making a game with lasers. I need to reflect the lasers against a rotated object, but I can't find the correct normal vector.

Example: Point A (0, 20) goes to point B (15, 5). My velocity is (1, -1) * Speed. A wall from point C (15, 0) to point D (15, 50). Wall standing upright.

Now I need to calculate the normal and normalize it (I know how to normalize). The normalize vector should be (-1, -1), but how do I calculate this? Do I need to use dotproduct, the angle or something else?





Aucun commentaire:

Enregistrer un commentaire