Reflect a vector in relation to another vector
Hey,
I'm stuck with a geometrical problem. I have vector A and vector V. I need to find vector A' that is the reflection of A in relation to V (see pic).
I'm stuck with a geometrical problem. I have vector A and vector V. I need to find vector A' that is the reflection of A in relation to V (see pic).
respect,
pk
iFrog is coming.
in 2D or 3D space?
2D space.
respect,
pk
iFrog is coming.
This one's pretty simple:
Code:
float Vector2_dot(Vector2 vector1, Vector2 vector2) {
return vector1.x * vector2.x + vector1.y * vector2.y;
}
Vector2 Vector2_reflect(Vector2 vector, Vector2 normal) {
Vector2 result;
float dot;
dot = Vector2_dot(vector, normal);
result.x = 2 * dot * normal.x - vector.x;
result.y = 2 * dot * normal.y - vector.y;
return result;
}
Awesome. Just trying it out (too many side quests).
...
Hey it's working !!! Thanks.
...
Hey it's working !!! Thanks.
respect,
pk
iFrog is coming.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Vector shapes | Miglu | 16 | 7,466 |
Sep 22, 2010 07:52 AM Last Post: Miglu |
|
| Signed Distance Fields for Alpha Tested Magnification of Vector Textures | maximile | 2 | 4,586 |
Mar 29, 2010 10:59 AM Last Post: Skorche |
|
| New to obj-c and have no idea where to start: vector graphics | billybob | 1 | 2,251 |
May 27, 2009 11:17 AM Last Post: billybob |
|
| Vector graphics rendering: Best approach? | Luipaard | 5 | 4,557 |
Sep 28, 2007 08:40 AM Last Post: TomorrowPlusX |
|
| Vector (Normal) Map blending operations? | kelvin | 10 | 5,913 |
Mar 16, 2007 04:31 PM Last Post: OneSadCookie |
|

