## 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()`
Constructor
```Line2D​(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
Modifier and Type Method Description
`double` `calcAngle()`
calculates the angle between the projection of this line onto
yz-plane and the x-axis
`double` `calcAngle​(Line2D line)`
calculates the angle between this line and line
`double` `calcDist​(Vector2D v)`
calculates the shortest distance between point v and the infinite
line.
`Vector2D` `calcUnitNormal()`
calculates the unit normal of the line
`void` `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 line
`Vector2D` `p2()`
second point on the line
• ### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### 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] point
`p2` - [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 1
`y1` - [in] y coordinate of point 1
`x2` - [in] x coordinate of point 2
`y2` - [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 against
`res` - [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