0
\$\begingroup\$

I recently asked a question here: How would I check the range against the entirety of an enemy object, and not just it's transform.position?

That was accurately answered, and works perfectly fine. However, now I need to find the distance from the center of a non-rectangular object to it's edge as illustrated here: enter image description here

I have the length of Side A, and the angle between Side A and Side C, as well as the angle between Side A and Side B. I am missing a couple things:

  • The length of Side B
  • The length of Side C

My end goal is to get the length of side C. It is important to note that my math skills are barely comparable to first year college algebra. I heavily rely on the methods provided within Unity to calculate dot products, angles, and distances without much understanding of their inner workings.

How would I go about accomplishing this?

\$\endgroup\$
  • 3
    \$\begingroup\$ Is your object always an equilateral hexagon? Because if so, you know angle AB, as well (60°). Given that, you know angle BC = (180 - (60 + angleAC)). And once you know 1 side and its opposite angle, you can use the law of sines to find the others. You can also use the law of cosines in many convenient cases. \$\endgroup\$ – user1118321 May 6 '15 at 2:48
  • \$\begingroup\$ Thanks for the reply, your insight made me realize I can get the AB angle even if it's not equilateral because I know the direction of both vectors that make up that corner. I will read into the law of sines and consines \$\endgroup\$ – Douglas Gaskell May 6 '15 at 4:18
  • \$\begingroup\$ You should convert the comment to an answer and mark this question as solved. \$\endgroup\$ – tbkn23 May 7 '15 at 4:45
  • \$\begingroup\$ How do I mark his question as the answer? Or do I write it myself? \$\endgroup\$ – Douglas Gaskell May 7 '15 at 6:17
  • \$\begingroup\$ His comment* I meant \$\endgroup\$ – Douglas Gaskell May 7 '15 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.