Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Inasnum · Jun 17, 2020 at 03:17 AM · 3dtrigonometry

Trigonometry In 3D Space

Apologies if this has been asked, but I can't find an answer specific enough that I can understand it.


I'm trying to perform some trig in 3D space in order to calculate a point in the form of a Vector3. I have the angle ('t' in the image below) and the Vector3 coordinates of the 't' corner and the right angle corner. I need to calculate the remaining hypotenuse-opposite corner in C# script. However, I don't know where or at what orientation this triangle is going to appear in space when the calculation takes place, so I need to be able to calculate the hypotenuse-opposite corner as a Vector3 with just the given points and angles. In case it's important, I also know a point on the hypotenuse.


Can anyone give me some examples or direction that are easy to digest for someone new to 3D worldspace math?


For reference: Right Triangle

Comment
Add comment
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

1 Reply

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

Answer by Namey5 · Jun 17, 2020 at 09:21 AM

Without knowing how the triangle is to be oriented, it isn't really possible to find the point using just the other two corners and an angle. However, if you already know a point on the hypotenuse then we can use that to figure out the orientation of the triangle;

 //Where;
 // - t = angle in radians. if t is in degrees then you can multiply it by Mathf.Deg2Rad
 // - pT = the 3D coords of the known corner
 // - pR = the 3D coords of the right-angle
 // - pH = the 3D coords of a point on the hypotenuse
 
 //First, we need to find the length of the adjacent side
 float adjacent = Vector3.Distance (pT, pR);
 
 //Then, we can use that and some trig to find the length of the hypotenuse
 // - cos (t) = adj / hyp
 // - hyp = adj / cos (t)
 float hypotenuse = adjacent / Mathf.Cos (t);
 
 //Now, we can find the direction of the final corner from pT by subtracting it from pH and normalising the vector
 Vector3 pTH = (pH - pT).normalized;
 
 //Which we can then add to pT and scale by the length of the hypotenuse to find the coordinates of the remaining corner
 Vector3 corner = pT + pTH * hypotenuse;
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 Inasnum · Jun 19, 2020 at 04:04 AM 0
Share

Thank you! This is exactly what I needed to make some progress.

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

168 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

Related Questions

How to make proper yaw effects in 3D space exploration game? 1 Answer

How can I calculate the angle between two adjacent triangles in 3D? (for detecting concave or convex triangles) 1 Answer

Unity Based Telegram Channel? 0 Answers

Assigning joints connected body 0 Answers

how do i join a colab project 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