Tabnine Logo
LineSegment2d.percentageAlongLineSegment
Code IndexAdd Tabnine to your IDE (free)

How to use
percentageAlongLineSegment
method
in
us.ihmc.robotics.geometry.LineSegment2d

Best Java code snippets using us.ihmc.robotics.geometry.LineSegment2d.percentageAlongLineSegment (Showing top 6 results out of 315)

origin: us.ihmc/IHMCRoboticsToolkit

private boolean isBetweenEndpoints(double x, double y, double epsilon)
{
 double alpha = percentageAlongLineSegment(x, y);
 if (alpha < epsilon)
   return false;
 if (alpha > 1.0 - epsilon)
   return false;
 return true;
}
origin: us.ihmc/IHMCRoboticsToolkit

public double percentageAlongLineSegment(FramePoint2d point2d)
{
 checkReferenceFrameMatch(point2d);
 return lineSegment.percentageAlongLineSegment(point2d.getPoint());
}
origin: us.ihmc/IHMCRoboticsToolkit

/**
* Computes a percentage along this line segment representing the location of the given point once projected onto this line segment.
* The returned percentage is in ] -&infin;; &infin; [, {@code 0.0} representing {@code lineSegmentStart}, and {@code 1.0} representing {@code lineSegmentEnd}.
* <p>
* For example, if the returned percentage is {@code 0.5}, it means that the projection of the given point is located at the middle of the line segment.
* The coordinates of the projection of the point can be computed from the {@code percentage} as follows:
* <code>
* Point2d projection = new Point2d(); </br>
* projection.interpolate(lineSegmentStart, lineSegmentEnd, percentage); </br>
* </code>
* </p>
* <p>
* Edge cases:
* <ul>
*    <li> if the length of the given line segment is too small, i.e. {@code lineSegmentStart.distanceSquared(lineSegmentEnd) < Epsilons.ONE_TRILLIONTH}, this method fails and returns {@link Double#NaN}.
* </ul>
* </p>
* 
* @param pointX the x-coordinate of the query point.
* @param pointY the y-coordinate of the query point.
* @return the computed percentage along this line segment representing where the point projection is located.
*/
public double percentageAlongLineSegment(Point2d point2d)
{
 return percentageAlongLineSegment(point2d.getX(), point2d.getY());
}
origin: us.ihmc/IHMCRoboticsToolkit

/**
* Compute the smallest distance from the point to this line segment.
* If the projection of the given point on this line segment results in a point that is outside the line segment, the distance is computed between the given point and the closest line segment end point.
*/
@Override
public double distance(Point2d point)
{
 double alpha = percentageAlongLineSegment(point);
 if (alpha <= 0.0)
 {
   return point.distance(endpoints[0]);
 }
 else if (alpha >= 1.0)
 {
   return point.distance(endpoints[1]);
 }
 else
 {
   // Here we know the projection of the point belongs to the line segment.
   // In this case computing the distance from the point to the line segment is the same as computing the distance from the point the equivalent line.
   return GeometryTools.distanceFromPointToLine(point, endpoints[0], endpoints[1]);
 }
}
origin: us.ihmc/CommonWalkingControlModules

private void solve(CoMHeightPartialDerivativesData coMHeightPartialDerivativesDataToPack, Point2d queryPoint, boolean isInDoubleSupport)
 double splineQuery = projectionSegment.percentageAlongLineSegment(queryPoint) * projectionSegment.length();
origin: us.ihmc/CommonWalkingControlModules

Point2d nextPoint2d = new Point2d(nextContactFramePosition.getX(), nextContactFramePosition.getY());
line2d.orthogonalProjectionCopy(nextPoint2d);
xSNext = projectionSegment.percentageAlongLineSegment(nextPoint2d) * projectionSegment.length();
us.ihmc.robotics.geometryLineSegment2dpercentageAlongLineSegment

Javadoc

Computes a percentage along this line segment representing the location of the given point once projected onto this line segment. The returned percentage is in ] -∞; ∞ [, 0.0 representing lineSegmentStart, and 1.0 representing lineSegmentEnd.

For example, if the returned percentage is 0.5, it means that the projection of the given point is located at the middle of the line segment. The coordinates of the projection of the point can be computed from the percentage as follows: Point2d projection = new Point2d();
projection.interpolate(lineSegmentStart, lineSegmentEnd, percentage);

Edge cases:

  • if the length of the given line segment is too small, i.e. lineSegmentStart.distanceSquared(lineSegmentEnd) < Epsilons.ONE_TRILLIONTH, this method fails and returns Double#NaN.

Popular methods of LineSegment2d

  • <init>
  • set
  • areEndpointsTheSame
  • getFirstEndpoint
  • getFirstEndpointCopy
  • getFirstEndpointX
  • getFirstEndpointY
  • getSecondEndpoint
  • getSecondEndpointX
  • getSecondEndpointY
  • getSecondEndpointCopy
  • length
  • getSecondEndpointCopy,
  • length,
  • orthogonalProjection,
  • applyTransform,
  • applyTransformAndProjectToXYPlane,
  • checkEndpointsDistinct,
  • checkIsTransformationInPlane,
  • distance,
  • dotProduct

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • getApplicationContext (Context)
  • findViewById (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now