Jump to content

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


distraub
 Share

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?

https://www.babylonjs-playground.com/#2I0VXX#28

 

Link to comment
Share on other sites

  • 4 months later...

the function showAngleSectors() here https://github.com/jbousquie/UserFunctions/blob/master/showAngleSector.js  does exactly what you need

origin is the center of the sphere,  vector1 your first point, vector2 your second point and radius the sphere radius

https://www.babylonjs-playground.com/#FUK3S#7

Link to comment
Share on other sites

  • 5 months later...
  • 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).

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...