Package pointgon
Class Vertex
java.lang.Object
pointgon.Vertex
- All Implemented Interfaces:
Serializable
,Comparable<Vertex>
Class for vertices (perimeter and holes) of a pointgon.
- Since:
- 2005.02.18 (Christian Borgelt)
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compare this vertex to another.double
distance
(double x, double y) Compute the distance to a given point.double
Compute the distance to a given vertex.int
horzLineCuts
(Vertex src, Vertex dst) Check whether a horizontal line through the vertex cuts an edge.boolean
Check whether a line through the vertex cuts an edge.boolean
Check whether a line through the vertex cuts an edge.boolean
Check whether a line through the vertex cuts an edge.boolean
Check whether a line through the vertex cuts an edge.boolean
Check whether a line through the vertex cuts an edge.boolean
Check whether the vertex is inside a triangle.boolean
Check whether the vertex is inside a triangle.boolean
Check the position of the vertex relative to an edge.boolean
Check the position of the vertex relative to an edge.boolean
Check the position of the vertex relative to an edge.boolean
Check the position of the vertex relative to an edge.boolean
Check the position of the vertex relative to an edge.boolean
Check the position of the vertex relative to an edge.int
Check the position of the vertex relative to an edge.toString()
Create a string description of the vertex.
-
Field Details
-
id
public int idvertex identifier -
x
public double xx-coordinate of vertex -
y
public double yy-coordinate of vertex
-
-
Constructor Details
-
Vertex
public Vertex(double x, double y) Create a vertex.- Parameters:
x
- the x-coordinate of the vertexy
- the y-coordinate of the vertex- Since:
- 2005.02.18 (Christian Borgelt)
-
-
Method Details
-
distance
public double distance(double x, double y) Compute the distance to a given point.- Parameters:
x
- the x-coordinate of the pointy
- the y-coordinate of the point- Returns:
- the distance to the given point
- Since:
- 2005.02.18 (Christian Borgelt)
-
distance
Compute the distance to a given vertex.- Parameters:
v
- the vertex to compute the distance to- Returns:
- the distance to the given vertex
- Since:
- 2005.02.18 (Christian Borgelt)
-
sideOf
Check the position of the vertex relative to an edge.- Parameters:
src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- -1, if the vertex is in the left, +1, if the vertex is on the right, and 0 if the vertex is on the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isLeftOf
Check the position of the vertex relative to an edge.- Parameters:
src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the vertex os to the left of the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isLeftOf
Check the position of the vertex relative to an edge.- Parameters:
edge
- the edge to check- Returns:
- whether the vertex os to the left of the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isRightOf
Check the position of the vertex relative to an edge.- Parameters:
src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the vertex is to the right of the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isRightOf
Check the position of the vertex relative to an edge.- Parameters:
edge
- the edge to check- Returns:
- whether the vertex is to the right of the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isPartOf
Check the position of the vertex relative to an edge.- Parameters:
src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the vertex is on the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isPartOf
Check the position of the vertex relative to an edge.- Parameters:
edge
- the edge to check- Returns:
- whether the vertex is on the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isInside
Check whether the vertex is inside a triangle.- Parameters:
a
- the first vertex of the triangleb
- the second vertex of the trianglec
- the third vertex of the triangle- Returns:
- whether the vertex is inside the triangle
- Since:
- 2005.02.18 (Christian Borgelt)
-
isInsideX
Check whether the vertex is inside a triangle.(check both orders of the triangle corners)
- Parameters:
a
- the first vertex of the triangleb
- the second vertex of the trianglec
- the third vertex of the triangle- Returns:
- whether the vertex is inside the triangle
- Since:
- 2005.02.18 (Christian Borgelt)
-
horzLineCuts
Check whether a horizontal line through the vertex cuts an edge.- Parameters:
src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the line cuts the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isects
Check whether a line through the vertex cuts an edge.- Parameters:
dx
- the x-coordinate of the direction vector of the linedy
- the y-coordinate of the direction vector of the linesrc
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the line cuts the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isects
Check whether a line through the vertex cuts an edge.- Parameters:
to
- the vertex the line leads to (from this vertex)src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the line cuts the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isects
Check whether a line through the vertex cuts an edge.- Parameters:
to
- the vertex the line leads to (from this vertex)edge
- the edge to check- Returns:
- whether the line cuts the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isectsX
Check whether a line through the vertex cuts an edge.- Parameters:
to
- the vertex the line leads to (from this vertex)src
- the first vertex of the edgedst
- the second vertex of the edge- Returns:
- whether the line cuts the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
isectsX
Check whether a line through the vertex cuts an edge.- Parameters:
to
- the vertex the line leads to (from this vertex)edge
- the edge to check- Returns:
- whether the line cuts the edge
- Since:
- 2005.02.18 (Christian Borgelt)
-
compareTo
Compare this vertex to another.- Specified by:
compareTo
in interfaceComparable<Vertex>
- Parameters:
obj
- the other vertex- Returns:
- the sign of the coordinate difference (x-coordinate takes precedence over y-coordinate)
- Since:
- 2005.02.18 (Christian Borgelt)
-
toString
Create a string description of the vertex.
-