Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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 /
  • Help Room /
avatar image
0
Question by JeyP4 · Jun 03, 2018 at 11:02 PM · rotationquaterniondirectionanglesangleaxis

How can I find direction with known 2 projection angles on xz and yz planes?

alt text

I think 'A' vector3 direction would be
Quaternion.AngleAxis( A, transform.up) * transform.forward &
'B' vector3 direction would be
Quaternion.AngleAxis( -B, transform.right) * transform.forward

But I dont know the vector3 direction of 'u' Vector.
I need direction for Raycasting.
Can someone help with this. Thanx Cheers:)

vector3.jpg (19.8 kB)
Comment
Add comment · Show 1
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 JeyP4 · Jun 03, 2018 at 11:11 PM 0
Share

just FYI, as trigonometry says B != C alt text

vector3-2.jpg (24.1 kB)

2 Replies

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

Answer by JeyP4 · Jun 05, 2018 at 11:41 AM

I find below code working for raycasting direction :)

 Vector3 u = new Vector3 (-Mathf.Tan (B * Mathf.Deg2Rad), Mathf.Tan (A * Mathf.Deg2Rad), 1);
 u= Quaternion.Euler(transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z) * u;

But anyways many thanx for considering my question to answer.

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 Scribe · Jun 09, 2018 at 08:53 AM 1
Share

For anyone looking at this question in future, I'm pretty sure the use of the Tan function here is incorrect and should have been using Sin ins$$anonymous$$d.

The reason I say that is because my interpretation of the information we have here is we know:

  1. The angle

  2. The length of the hypotenuse (the longest side) which is the length of whatever vector we are rotating, in this case it's 1

And we want to find, the length of the side opposite the angle. The remaining side of the triangle is usually called the adjacent.


Since we have that Tan(angle) = opposite / adjacent I don't think we can use it, as we don't know the adjacent side length.

Ins$$anonymous$$d we can use Sin(angle) = opposite / hypotenuse since here the hypotenuse is always going to be of length 1, this is the same as Sin(angle) = opposite.


I think the arguments are also in the wrong order based on the image, as the angle A should relate to the x-axis and angle B to the y-axis.

The final answer for most users cases would look more like:

 Vector3 u = transform.rotation * new Vector3 ($$anonymous$$athf.Sin(A * $$anonymous$$athf.Deg2Rad), $$anonymous$$athf.Sin(B * $$anonymous$$athf.Deg2Rad), 1);


I'm glad you found an answer that works for you JeyP4, just explaining for the next person!

avatar image
1

Answer by Scribe · Jun 04, 2018 at 08:53 PM

The easiest way looks to be projecting the vector calculated from A onto the X axis and adding to the vector calculated for B (or the same technique the other way around)

 Vector3 aVec = ...;
 Vector3 bVec = ...;
 Vector3.Project(aVec, transform.right)+bVec;
Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

176 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 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 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

Determining if my target is standing upright 4 Answers

Copy Roll From one Gameobject to another Without other rotations effecting it 0 Answers

The direction my camera is rotating should indicate the direction my object facing 0 Answers

Need solution for rotation with player input of X, Y, Z 1 Answer

What's the reverse of Quaternion.AngleAxis? 0 Answers


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