-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Finding tangent line to circle at point #53
Comments
Thanks @tangert . That's a definitely a good function for Pts, and maybe also getting the 4 tangent lines between 2 circles. I'll try to get to this soon. If you need it quickly, I think the simplest implementation would be using circle-circle intersection to find the 2 tangent points -- something like this: |
Hm- but how easily does this solution all you to draw a tangent line at the point A? Maybe I'm not seeing it correctly. For now, the easiest solution for me was to create a vertical line at a given point, then rotate it by the angle between that point and the center of the circle. The example below creates a circle from a given center point and draws the tangent line according to the space's pointer.
You can play with what I'm doing with it here (it's a little slow): https://l9r723q4l9.codesandbox.io/ I think another good approach would be to simply have a function for |
Hi Tyler, I see -- seems like you're looking for something simpler. If I understand correctly, I think a simple way is to get a vector from pointer to circle's center, and then find its orthogonal vectors. You can use let vec = space.pointer.$subtract( space.center );
let r = vec.magnitude();
let circle = Circle.fromCenter( space.center, r );
let ortho = Geom.perpendicular( vec );
ortho.add( space.center.$add( vec ) ); // add circle's position back
form.strokeOnly("#fff").circle( circle ).line( [space.center, space.pointer] );
form.stroke("#fe0", 3).line( ortho ); Take a look also at these demos which may be relevant to what you want to do: Some quick tips:
Hope these helps! |
Awesome! That helps a lot. I tried using the perpendicular function earlier but couldn't get it to work- this makes it a lot more clear. |
I figure this should probably be a built in function to
Circle
orPt
orLine
. I'm implementing it myself now thoughThe text was updated successfully, but these errors were encountered: