• 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 spinnerbox · Oct 06, 2015 at 09:00 AM · mathfanglespoints

Find two points which are on 120 degrees from a third point.

I drew this graphic: circle-points

If you check better all 4 points including the center of the circle are on Z = z1. I know the center of the circle which is (x1, y1, z1). I also know the top point which is (x1, y1 + r, z1). And I know that the other two points are on angle of 120 degrees. How can I find x2, y2, x3 and y3 using some useful functions from Unity.

Note: I know pytagorean theroem. No need to mention it.

I could possibly make some math with lines on a plane and where they intersect but that seems rather complex.

circle1.png (19.9 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 saschandroid · Oct 06, 2015 at 09:15 AM 0
Share

You can rotate the point (x1, y1+r,z1) around the center by 120/240 degrees to get the other two points (quaternion * vector3).

Edit (to be more specific): - move the the center (and with it the first) point to (0,0,0) - rotate the first point by 120degrees (with quaternion * vector3) for the second - and then again for the third - move center (and all other points) back to original position.

3 Replies

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

Answer by Garazbolg · Oct 14, 2015 at 08:48 AM

Or you could do it with trigonometry :

x2 = x1 + cos(30°) * r;

x3 = x1 - cos(30°) * r;

y2 = y3 = y1 - sin(30°) * r;

but to make it even simpler 'sin(30°)' is equal to 1/2

so y2 = y3 = y1 - r/2;

In Unity :

 float cos30_R = Mathf.Cos(30 * Mathf.Deg2Rad) * r;
 
 x2 = x1 + cos30_R;
 x3 = x1 -  cos30_R;
 
 y2 = y3 = y1 - r/2;

It should use less ressources then your method.

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
avatar image
1

Answer by 0potable · Oct 06, 2015 at 09:18 AM

One quick dirty way on top of my head : use a Transform as a helper.

1) transform.position = circleCenter

2) transform.LookAt(topPoint, Vector3.up)

3) transform.Rotate(Vector3.up * 120f)

4) transform.TransformPoint(Vector3.forward * radius) <<

5) Repeat step 3 & 4 for the last point

Note that the Vector3.up of the second step need to represent the "up" direction of the circle.

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
avatar image
0

Answer by spinnerbox · Oct 14, 2015 at 07:32 AM

This function works perfectly:

  function RotatePointAroundPivot(point: Vector3, pivot: Vector3, angles: Vector3): Vector3 {
    var dir: Vector3 = point - pivot; // get point direction relative to pivot
    dir = Quaternion.Euler(angles) * dir; // rotate it
    point = dir + pivot; // calculate rotated point
    return point; // return it
  }

From this question: http://answers.unity3d.com/questions/532297/rotate-a-vector-around-a-certain-point.html

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.

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

31 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

Related Questions

How To Calcutale New Position and Angle On The Line Objects 2 Answers

Clamp rotation of sprite? 0 Answers

How to find acute and obtuse angle between 2 points 1 Answer

Distance calculation problem 1 Answer

Math question 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