Hello,

I am currently working on a Cesium project where I want to connect cities on the planet with polylines. This is quite easy when using the centerpoint of the city, however I need to have the lines end not at the center but rather on a virtual circle which defined the cities limits.

So I’d need to find the intersection point of the polyline and a ( non rendered ) sphere, which encapsulates the cities boundaries,

This vector / circle intersection is easy to do in 2D but I cant wrap my head around how to do that with a 3D line following a globe’s surface.

Does Cesium provide tools to do that, or do I need to write my own?

Edit:

I tried with a line / plane intersection but could not get that to work either.

Here is a sandcastle example

Thanks!

Perhaps there’s another way to go about it. Determine total distance city to city, subtract from that distance the desired radius, then travel along that line only as far as that result distance to determine the point to draw to?

https://cesium.com/docs/cesiumjs-ref-doc/EllipsoidGeodesic.html

new Cesium.EllipsoidGeodesic(start, end, ellipsoid)

Initializes a geodesic on the ellipsoid connecting the two provided planetodetic points.

Then use its surfaceDistance property and subtract radius from this method

interpolateUsingSurfaceDistance(distance, result)

Provides the location of a point at the indicated distance along the geodesic.

Great! Thank you. That also helped my other question

I’m glad that it helped! I suppose the other question was Geodesic related as well.

EDIT: oh, this question! How to split a polyline in half

Here is a sandcastle in case anyone has the same question:

Neat example!

I noticed you’re using explicit degree / radian conversions. You might like to know about `Cartographic.fromDegrees()`

. (Also: `Cartesian3.fromDegrees`

/ `.fromDegreesArray`

, `Cesium.Math.toDegrees`

, etc.)

Thanks, using this sandcastle I just discovered that the interpolate function can extrapolate as well, I must have messed up when trying it before.

1 Like