how to find what are the lat longs intersecting on polyline

613 views
Skip to first unread message

lakshmi...@gmail.com

unread,
Apr 11, 2018, 8:06:45 AM4/11/18
to cesium-dev
1. A concise explanation of the problem you're experiencing.
how to find what are the lat longs intersecting on polyline

2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.


3. Context. Why do you need to do this? We might know a better way to accomplish your goal.


Function to find what are the lat longs intersecting on polyline

4. The Cesium version you're using, your operating system and browser.
1.39 cesuim, window 10

Gabby Getz

unread,
Apr 12, 2018, 10:08:41 AM4/12/18
to cesium-dev
Hi,

I don't think there's a way to directly check if something intersects with a polyline, but you can check yourself using the positions and IntersectionTests.

Thanks,
Gabby

Dhana lakshmi

unread,
Apr 13, 2018, 3:14:51 AM4/13/18
to cesiu...@googlegroups.com
Hi Gabby,


I have tried below code to find intersecting coordinates between from start to end lat longs.

I didn't get any data.


please help me with functionality.

below code i tried:

--------------------

where  startin point=  -117.12639396110795,48.830170186405645. end point point -== -105.37173110114797,49.193286389956334  of line segment


there are the points (-113.28261469013405,32.735124178321776, -112.76252905478525,32.90082475020003)which are in between  line segment , where i need find, these 2 points are intersecting line segment

var viewer = new Cesium.Viewer('cesiumContainer');
var camera = viewer.camera;
    var ellipsoid = viewer.scene.globe.ellipsoid;


var origin = Cesium.Cartesian3.fromDegrees(-117.12639396110795,48.830170186405645);
var normal = ellipsoid.geodeticSurfaceNormal(origin);


var p0 = Cesium.Cartesian3.fromDegrees(-113.28261469013405,32.735124178321776);
var p1 = Cesium.Cartesian3.fromDegrees(-112.76252905478525,32.90082475020003);
var center=Cesium.Cartesian3.fromDegrees(-105.37173110114797,49.193286389956334);
var sphere= new Cesium.BoundingSphere(center, 0);


// convert the triangle composed of points (p0, p1, p2) to three triangles that don't cross the plane
var intersections = Cesium.IntersectionTests.lineSegmentSphere(p0, p1, sphere);

console.log(intersections);


----------

Regards
Dhana


 


--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/uXpaDMlgrcs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dhana lakshmi

unread,
Apr 13, 2018, 3:38:09 AM4/13/18
to cesiu...@googlegroups.com
Hi 

as per github tried below code, received as "undefined". please suggest.





code:
---

var viewer = new Cesium.Viewer('cesiumContainer');


var sphere = Cesium.BoundingSphere.fromCornerPoints(new Cesium.Cartesian3(-0.5, -0.5, -0.5), new Cesium.Cartesian3(0.5, 0.5, 0.5));
console.log("sphere==");
console.log(sphere);


    var viewer = new Cesium.Viewer('cesiumContainer');
var camera = viewer.camera;
    var ellipsoid = viewer.scene.globe.ellipsoid;


var origin = Cesium.Cartesian3.fromDegrees(-117.12639396110795,48.830170186405645);
var normal = ellipsoid.geodeticSurfaceNormal(origin);

var plane = Cesium.Plane.fromPointNormal(origin, normal);

var p0 = Cesium.Cartesian3.fromDegrees(-113.28261469013405,32.735124178321776);
var p1 = Cesium.Cartesian3.fromDegrees(-112.76252905478525,32.90082475020003);

// find the intersection of the line segment from p0 to p1 and the tangent plane at origin.
var intersection = Cesium.IntersectionTests.lineSegmentPlane(p0, p1, plane);

console.log(intersection);


Regards
Dhana



Gabby Getz

unread,
Apr 16, 2018, 11:00:25 AM4/16/18
to cesium-dev
Hi Dhana,

I'm still not sure what you are trying to accomplish. Are you trying to test if those two point intersect the line segment, or is the second set of points it's own line segment?

I think this is not so much a problem with the Cesium API, but rather a geometry problem. You might have more success asking on a Math forum. Then if you then have specific questions about Cesium ask them here.

Thanks,
Gabby

Dhana lakshmi

unread,
Apr 16, 2018, 2:18:56 PM4/16/18
to cesiu...@googlegroups.com
Hi Gabby,

I have tried and implemented the functionality. Thank you.

Regards
Dhana

Dhana lakshmi

unread,
Apr 18, 2018, 5:27:03 AM4/18/18
to cesiu...@googlegroups.com
Hi Gabby,

Is that possible to compare with an array intersecting between starting and ending point?

I want to test an array of coordinates in center with starting and ending point.

something like this as below example: Please guide me.



var viewer = new Cesium.Viewer('cesiumContainer');





 var p0 = Cesium.Cartesian3.fromDegrees([78.38126509772302,17.451123346716912]);
var p1 = Cesium.Cartesian3.fromDegrees([78.3815350820249,17.451429693791102]);
                                              

var center=Cesium.Cartesian3.fromDegreesArray([78.38133429279841,17.451203141578144]);

var sphere= new Cesium.BoundingSphere(center,0);
alert(sphere);


var intersections = Cesium.IntersectionTests.lineSegmentSphere(p0, p1, sphere);

alert(intersections);


Regards
Dhana

Gabby Getz

unread,
Apr 20, 2018, 10:40:48 AM4/20/18
to cesium-dev
Hi Dhana, 

There's nothing special in the Cesium API to do that, you should be able to iterate through an array of Cartesian3's and tests the intersections.

Thanks,
Gabby
Reply all
Reply to author
Forward
0 new messages