us.ihmc.robotics.geometry.GeometryTools.isPointOnLeftSideOfLine()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(3.2k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中us.ihmc.robotics.geometry.GeometryTools.isPointOnLeftSideOfLine()方法的一些代码示例,展示了GeometryTools.isPointOnLeftSideOfLine()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GeometryTools.isPointOnLeftSideOfLine()方法的具体详情如下:
包路径:us.ihmc.robotics.geometry.GeometryTools
类名称:GeometryTools
方法名:isPointOnLeftSideOfLine

GeometryTools.isPointOnLeftSideOfLine介绍

[英]Returns a boolean value, stating whether a 2D point is on the left side of an infinitely long line defined by two points. "Left side" is determined based on order of lineStart and lineEnd.

For instance, given the lineStart coordinates x = 0, and y = 0, and the lineEnd coordinates x = 1, y = 0, a point located on the left side of this line has a negative y coordinate.

This method will return false if the point is on the line.
[中]返回一个布尔值,说明二维点是否位于由两点定义的无限长直线的左侧。“左侧”根据lineStart和lineEnd的顺序确定。
例如,给定直线起点坐标x=0和y=0,以及直线终点坐标x=1和y=0,位于该直线左侧的点具有负y坐标。
如果点在直线上,此方法将返回false。

代码示例

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

/**
* Returns true only if the point is inside the triangle defined by the vertices a, b, and c.
* The triangle can be clockwise or counter-clockwise ordered.
* 
* @param point the point to check if lying inside the triangle. Not modified.
* @param a first vertex of the triangle. Not modified.
* @param b second vertex of the triangle. Not modified.
* @param c third vertex of the triangle. Not modified.
* @return {@code true} if the query is exactly inside the triangle. {@code false} if the query point is outside triangle or exactly on an edge of the triangle.
*/
public static boolean isPointInsideTriangleABC(Point2d point, Point2d a, Point2d b, Point2d c)
{
 // This makes the assertion working for both clockwise and counter-clockwise ordered vertices.
 RobotSide sideToCheck = isPointOnLeftSideOfLine(b, a, c) ? RobotSide.LEFT : RobotSide.RIGHT;
 if (isPointOnSideOfLine(point, a, b, sideToCheck))
   return false;
 if (isPointOnSideOfLine(point, b, c, sideToCheck))
   return false;
 if (isPointOnSideOfLine(point, c, a, sideToCheck))
   return false;
 return true;
}

代码示例来源:origin: us.ihmc/ihmc-robotics-toolkit-test

@ContinuousIntegrationTest(estimatedDuration = 0.0)
@Test(timeout = 30000)
public void testIsPointOnLeftSideOfLine()
{
 FramePoint3D lineStart = new FramePoint3D(ReferenceFrame.getWorldFrame(), 5.0, 0.0, 0.0);
 FramePoint3D lineEnd = new FramePoint3D(ReferenceFrame.getWorldFrame(), 5.0, 10.0, 0.0);
 FramePoint3D point = new FramePoint3D(ReferenceFrame.getWorldFrame(), 10, 5, 0.0);
 boolean expectedReturn = false;
 boolean actualReturn = GeometryTools.isPointOnLeftSideOfLine(point, lineStart, lineEnd);
 assertEquals("return value", expectedReturn, actualReturn);
 /** @todo fill in the test code */
}

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

while (decrementP ^ GeometryTools.isPointOnLeftSideOfLine(lineQEnd, linePStart, linePEnd))
while ((!decrementP) ^ GeometryTools.isPointOnLeftSideOfLine(linePEnd, lineQStart, lineQEnd))

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

Point2d checkPointPoint2d = new Point2d(point.getX(), point.getY());
return isPointOnLeftSideOfLine(checkPointPoint2d, lineStartPoint2d, lineEndPoint2d);

代码示例来源:origin: us.ihmc/IHMCRoboticsToolkit

Point2d lineEnd = new Point2d(currentPolygonPPoint);
lineEnd.add(caliperForPolygonP);
boolean isOnLeft = GeometryTools.isPointOnLeftSideOfLine(currentPolygonQPoint, lineStart, lineEnd);
boolean wasOnLeft = isOnLeft;
  lineEnd = new Point2d(currentPolygonPPoint);
  lineEnd.add(caliperForPolygonP);
  isOnLeft = GeometryTools.isPointOnLeftSideOfLine(currentPolygonQPoint, lineStart, lineEnd);

相关文章