# solved Drawing an Arc on a Sphere from Point A to point B

## Recommended Posts

Hey guys, I have been trying to do this for awhile, and feel like I am almost there.

I had been using Bezier Curves but it wasn't quite doing what I needed. I need to draw an arc made with lines between 2 points on the sphere, following the curve of the sphere.

I think  I am close on this playground but some of my math isn't right in the drawArcFromPoints function

Anyone think they can take a look and tell me where I am going wrong?

##### Share on other sites

And I finally figured it out.

##### Share on other sites

Well thought I figured it out but it doesn't exactly work for all points, sort of spirals on some.

##### Share on other sites

• 4 months later...

@distraubThis is awesome!!

The `projectLatLongToSphere` function was exactly what I needed for my current project.

##### Share on other sites

• 5 months later...

Wow Jerome

Sorry I didn't realize you came back and replied, you are awesome

##### Share on other sites

• 2 months later...

Apologies for bumping an old topic, here's my effort. It uses TransformNode.LookAt to create rotationQuaternions, and then Quaternion.Slerp to interpolate the line points: https://www.babylonjs-playground.com/ts.html#QIX6TN#11

Tap on the sphere to add more lines. The lines are fairly good, though can get a bit curvy depending on where on the sphere you tap  if one of the points is at the north pole (I guess because of this being the up axis of the look-at function? I wonder whether I could supply an alternate up axis in those cases).

On the plus side, there's no custom maths, it just uses BabylonJS methods. On the minus, I'm not sure I like adding/removing temporary TransformNodes to the scene just to jump on their LookAt methods (I tried using the Matrix.LookAt methods, but the results weren't good).

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.