• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Paperfrog · Feb 11, 2018 at 11:28 PM · vectorrelative

Find relative vector

Hi,

having aquired some knowledge of vectors, I thought I would figure this out myself, seems easy enough, but I just can't get my head around it at the moment. I want to find one relative (direction) vector from the relation of the two inital ones. Perhaps my image can show it better. So the blue vector should act like it's pointing at world [0, 1] and the purple result should then be what the red in that case would be relative to blue. So my thought is that I need to calculate some kind of offset and apply it to the red, but, yeah, any help would be appreceated.

alt text

relativevector.jpg (154.3 kB)
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Feb 12, 2018 at 07:42 PM 0
Share

for me blue points at 1,1. I don't know how you get red since I don't understand the next sentence really, but the opposite blue would be blue * -1. the problem really is how you get blue and in which context or could act like 0,1? by turning it?

avatar image Bunny83 hexagonius · Feb 12, 2018 at 08:02 PM 1
Share

I think he meant that the current angle between blue and red should say. So if the blue goes from (0.707,0.707) to (0,1) the red should go from (-1,0) to (-0.707,-0.707)

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Feb 12, 2018 at 08:08 PM

If i understood your question correctly you want the red vector to be 135° offsetted from the blue one (counter clockwise). One way is to just do this. Create a quaternion with an angle of 135° and just rotate the blue vector to get the red one.


Another way is to do it relatively. You can use Quaternion.FromToRotation and pass your old and new blue vector. This gives you a relative rotation (in your case 45°). Just rotate the red one by the same rotation.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Paperfrog · Feb 14, 2018 at 08:38 PM 0
Share

Yes, that's correctly understood, thanks for answering. I also ended up doing it in a similar fashion, works just fine. Not sure why anymore, but was thinking there might be a way to skip the angles and do it with just the coordinates of the vectors. But doesn't really make too much sense now, thinking about it.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

77 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Need to know euler angles of Vector3 direction relative to other Vector3 direction 1 Answer

Rotate a Vector Relative to Another Vector 1 Answer

Can relative velocity be calculated from relative direction vector 3 Answers

Imported model is rotated 90 degrees off of straight, can't use any transforms 1 Answer

change the length of the vector 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges