I want to know whether a line and a point intersect.

16 views
Skip to first unread message

조현준

unread,
Nov 18, 2020, 12:19:28 AM11/18/20
to OpenSceneGraph Users
*I wrote it using a translator. Please understand if there is any awkwardness in the sentence.*

One object is moving in the path A -> B, B->C, C-D (using AnimationPath).

And I need to know in what path the moving object is moving.

I think you need to know if the line and point intersect to figure this out.
I thought I should use LineSegmentIntersection to check whether a line and a point intersect.
I found the part in LineSegmentIntersection that sets the line (path) coordinates, but I don't find a function to check if the LineSegmentIntersection and point intersect.

-------example--------
osg::Vec3d start(128.0, 37.0, 250);       //wgs84, longitude, latitude, altitude
osg::Vec3d end(128.0, 37.0005, 750);  //wgs84, longitude, latitude, altitude

osg::ref_ptr<osg::Utill::LineSegmentIntersector> lis = NULL;
lis = new osgEarth::DPLineSegmentIntersector(start, end)
osgUtill::IntersectionVisitor iv(lis.get())

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

----------------------------------------------
osg::ref_ptr<osg::Node> node = _node
node->accept(iv);
if(lis->containsIntersections())
{
  ......................................

------------------------------------------------
I tried running it in the same way as above, but there was no true result even though the object coordinates belong to the line coordinates.
  I think the part of setting the point coordinates in that code is wrong. How do I set the point coordinates to get the desired result?
Reply all
Reply to author
Forward
0 new messages