Package org.robwork.sdurw_math
Class Line2D
- java.lang.Object
-
- org.robwork.sdurw_math.Line2D
-
public class Line2D extends java.lang.Object
Describes a line segment in 2D.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Line2D.IntersectResult
definition of intersection result values for the intersection test
between two lines.
-
Constructor Summary
Constructors Constructor Description Line2D()
ConstructorLine2D(double x1, double y1, double x2, double y2)
Creates a line between that intersect the two points (x1,y1) and (x2,y2).Line2D(long cPtr, boolean cMemoryOwn)
Line2D(Vector2D p1, Vector2D p2)
Creates a line between that intersect the two points p1 and p2.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
calcAngle()
calculates the angle between the projection of this line onto
yz-plane and the x-axisdouble
calcAngle(Line2D line)
calculates the angle between this line and linedouble
calcDist(Vector2D v)
calculates the shortest distance between point v and the infinite
line.Vector2D
calcUnitNormal()
calculates the unit normal of the linevoid
delete()
static long
getCPtr(Line2D obj)
Line2D.IntersectResult
getIntersect(Line2D line, Vector2D res)
calculates the intersection between two lines.double
getLength()
gets the length of thi line segment.Vector2D
p1()
first point on the lineVector2D
p2()
second point on the line
-
-
-
Constructor Detail
-
Line2D
public Line2D(long cPtr, boolean cMemoryOwn)
-
Line2D
public Line2D()
Constructor
-
Line2D
public Line2D(Vector2D p1, Vector2D p2)
Creates a line between that intersect the two points p1 and p2.- Parameters:
p1
- [in] pointp2
- [in] point
-
Line2D
public Line2D(double x1, double y1, double x2, double y2)
Creates a line between that intersect the two points (x1,y1) and (x2,y2).- Parameters:
x1
- [in] x coordinate of point 1y1
- [in] y coordinate of point 1x2
- [in] x coordinate of point 2y2
- [in] y coordinate of point 2
-
-
Method Detail
-
getCPtr
public static long getCPtr(Line2D obj)
-
delete
public void delete()
-
getIntersect
public Line2D.IntersectResult getIntersect(Line2D line, Vector2D res)
calculates the intersection between two lines. A intersection
point is only saved in res if the two lines are not parallel or coincident.
The intersection test does not take the segments into acount.- Parameters:
line
- [in] the line two test againstres
- [out] the point of intersection- Returns:
- the intersection type
-
calcAngle
public double calcAngle(Line2D line)
calculates the angle between this line and line- Parameters:
line
- [in] a line- Returns:
- the angle from this line to line
-
calcAngle
public double calcAngle()
calculates the angle between the projection of this line onto
yz-plane and the x-axis- Returns:
- the angle
-
calcDist
public double calcDist(Vector2D v)
calculates the shortest distance between point v and the infinite
line.- Parameters:
v
- [in] Point to which to calculate distance
-
getLength
public double getLength()
gets the length of thi line segment.- Returns:
- line segment length
-
p1
public Vector2D p1()
first point on the line
-
p2
public Vector2D p2()
second point on the line
-
calcUnitNormal
public Vector2D calcUnitNormal()
calculates the unit normal of the line
-
-