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 NeatFreak · Aug 15, 2019 at 12:05 PM · mathgeometrycircles

i have a line that goes through a circle. how can i find intersection points?

Hi. I have an point on edge of a circle and a direction where that point facing. When i draw a ray from that point i want that line to end at other edge of circle but i don't know how can i calculate that point because that line does not go from center(if it would then length of line would be same as diameter of circle). if i can find the other point then i can calculate the length of it by using chord of circle formula which is what i actually need.

alt text

imgg.png (22.1 kB)
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
4
Best Answer

Answer by Hellium · Aug 15, 2019 at 01:45 PM

Let's take the following image representing your situation.

alt text


O is the center of the circle

A is the point you know

B is the point you are looking for

v is the direction vector you know

α is the angle between AO and AB vectors

ω is the angle between OA and OB vectors


Because AOB is an isosceles triangle, the OAB and OBA angles are equal. And the sum of the angles of a triangle = 180°.


Pseudo code

 α  = Angle( O - A, v )
 ω  = 180 - 2 * a // because ω + α + α = 180
 BO = Rotate(A - O, ω)
 B  = O + BO


Translated in C#:

 private Vector3 ComputeB( Vector3 circleCenter, Vector3 circleNormal, Vector3 point, Vector3 direction )
 {
     float a = Vector3.SignedAngle( circleCenter - point, direction, circleNormal );
     float w = 0;
     if ( a >= 0 ) w = 180 - 2 * a; // because w + a + a = 180;
     else w = -( 180 + 2 * a );
     Vector3 BO = Quaternion.AngleAxis(w, -circleNormal) * (point - circleCenter);
     return circleCenter + BO;
 }


circle.jpg (23.8 kB)
Comment
Add comment · Show 3 · 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 NeatFreak · Aug 15, 2019 at 03:37 PM 0
Share

[SOLVED]Problem was y axis of center wasn't same as other positions and this caused miscalculations on angles.

Old Problem: Hey. Thanks you for your answer but i made few tests and it looks like there is have an offset to point. Can this be because of - 90 degree unity thing because unity handles rotation differently?

(it should be on top of red point on image but it's not and i did give the same direction as line's direction)

alt text

alt text

avatar image Hellium NeatFreak · Aug 15, 2019 at 04:11 PM 1
Share

The images are broken, can you upload them again?

When I tested, it seemed to work fine.

alt text

avatar image NeatFreak · Aug 15, 2019 at 04:41 PM 0
Share

It works perfectly fine. Thank you so much :) @Hellium alt text

screenshot.png (14.3 kB)

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

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

Circle-line Intersection Points 3 Answers

Find "real" rotation of box mesh 0 Answers

Hexagonal geodesic map 0 Answers

Intersection of a Plane and an object 0 Answers

Detecting if line cuts Polygon 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