Jump to content
• Advertisement

# Rotating a vector

This topic is 3007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

I have 2 vectors, a which intercepts with c. I am trying to find the vector b (See picture) Here's what I'm doing atm: θ = cos-1 ((a.c)/|a||c|) let x = ax and y = ay bx = x*cosθ - y*sinθ by = x*sinθ + y*cosθ but this isn't giving me the expected results?

#### Share this post

##### Share on other sites
Advertisement
Sorry for the very brief reply, don't have much time.

I'm assuming you are working in 2 dimensions. If so then first calculate the vector normal to C. This can be done using the formula: Cnorm = (-y, x), if C=(x,y). Normalize Cnorm.

Then the vector b is given by:

b = a - 2*(a.Cnorm)*Cnorm

Hope this helps.

#### Share this post

##### Share on other sites
Yes, I am working in 2D.
I fixed (I think) my method by using π-2θ instead of θ when calculating b.

Could somebody explain Weasa's method please?

#### Share this post

##### Share on other sites
See this article for details. Note that the reflection normal n is your c-vector, rotated 90 degrees.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
25
2. 2
JoeJ
20
3. 3
4. 4
5. 5
• Advertisement

• 9
• 9
• 46
• 41
• 23
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002053
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!