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 ROM · Aug 05, 2010 at 02:12 PM · mathcalculatetriangle

Calculating triangle side length based on hypotenuse?

Essentially as part of my application the sides of a triangle are calculated much like the first part of the attached image. This is done using a simple distance function. However later in the application the triangle can be scaled (1 to 1 so it remains the same shape), I continue knowing the distance (hypotenuse) but not the side edges, I've had real trouble allowing my application to calculate the side edges (part 2 of the diagram). If anyone could help then it would be greatly appreciated.

alt text

I've attempted using basic Pythagorus (b^2 = c^2 - a^2) but my application struggles with it and responds with "NaN".

For those who are interested I'm essentially building a "Scroll wheel" into my application where an object follows your finger when it's on the scroll wheel. When it's off of the scroll wheel it still follows it but only to the edge of the circle where it then stops. So if you drag your finger around the edge of the circle then it follows it round but only to the edge of the circle.

EDIT: I've attempted the following but it doesn't work. It's set inside a block that says if distance is greater than 40 then do this:

var AngleVar = ((Vector3.Angle(Vector3(Ball.position.x,Ball.position.y, 0), Vector3(MoveDist.x, MoveDist.y, 0)))/180);
Target2.position = Vector3((40 * Mathf.Cos(AngleVar)), (40 * Mathf.Sin(AngleVar)), Target2.position.z);

It doesn't limit the distance to 40 like it should and the rotation is not correct either. AngleVar is calculated correctly. When it's directly above "Ball" (Wheel centre) it is 1 and when directly below it is 0. I realise that Sin and Cos will flip round as I move around the circle but this code is not working an any segment.

Comment
Add comment · Show 3
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 spinaljack · Aug 05, 2010 at 02:18 PM 0
Share

This is pretty basic, if you know the angle of the triangle you can use trigonometry to find the other sides or if you're using vectors it's a simple case of subtraction. What script did you use to get that error?

avatar image ROM · Aug 05, 2010 at 02:40 PM 0
Share

I'm not using vectors so unfortunately that will not work. I tried your solution. The results are above. I'm sure I've done something wrong ^-^

avatar image DavidB · Aug 05, 2010 at 03:05 PM 0
Share

I'm having trouble figuring out what your code is doing exactly.. what is this Ball? and what is $$anonymous$$oveDist? Trig can be a bit wonky, but if you can give us a better sense of your code I can definitely help you solve this one.

In general terms you say you know all of the original sides of the triangle... and thus can find Theta (the angle of the triangle between the adjacent and hypotenuse). $$anonymous$$ake use of SOH CAH TOA (Sin(Theta) = opposite/hypotenuse etc) to find Theta for the original triangle, and then scale it appropriately... and use the Hypotenuse length and this known Theta to clone the tri

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Mike 3 · Aug 05, 2010 at 03:07 PM

Not entirely sure what the issue is here - you're scaling the triangle, can't you just scale the values too?

Multiply the values from the left triangle by 30/58.0 (Hypotenuse2/Hypotenuse1) and you get the right triangle values

Example using the standard 3 4 5 triangle:

1) Hypotenuse: 5, Opposite: 3, Adjacent: 4

2) Hypotenuse: 10

To get the Opposite and Adjacent values:

Opposite = 3 * 10/5 = 6

Adjacent = 4 * 10/5 = 8

Which matches with a 6 8 10 triangle like you'd expect

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

No one has followed this question yet.

Related Questions

Find position of pixel on sphere given position of pixel on texture 1 Answer

calculus help angels of a triangle 1 Answer

Why say Unity that 320* (1 / 320) = 0? 5 Answers

Calculate Position of Rigidbody after applying Force 0 Answers

Math question, center of triangle that is part of a square 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