Jump to content
  • Advertisement
Sign in to follow this  
MrPickle

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


Link to 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


Link to 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


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

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!