aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25/math
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sword25/math')
-rw-r--r--engines/sword25/math/polygon.cpp66
-rw-r--r--engines/sword25/math/polygon.h34
2 files changed, 0 insertions, 100 deletions
diff --git a/engines/sword25/math/polygon.cpp b/engines/sword25/math/polygon.cpp
index a83a8aa1dd..e8385c60c8 100644
--- a/engines/sword25/math/polygon.cpp
+++ b/engines/sword25/math/polygon.cpp
@@ -91,7 +91,6 @@ bool Polygon::init(int vertexCount_, const Vertex *vertices_) {
// Calculate properties of the polygon
_isCW = computeIsCW();
- _isConvex = computeIsConvex();
_centroid = computeCentroid();
return true;
@@ -103,11 +102,6 @@ bool Polygon::init(int vertexCount_, const Vertex *vertices_) {
bool Polygon::isCW() const {
return _isCW;
}
-
-bool Polygon::isCCW() const {
- return !isCW();
-}
-
bool Polygon::computeIsCW() const {
if (vertexCount) {
// Find the vertex on extreme bottom right
@@ -147,51 +141,6 @@ int Polygon::findLRVertexIndex() const {
return -1;
}
-
-// Testing for Convex / Concave
-// ------------------------
-
-bool Polygon::isConvex() const {
- return _isConvex;
-}
-
-bool Polygon::isConcave() const {
- return !isConvex();
-}
-
-bool Polygon::computeIsConvex() const {
- // Polygons with three or less vertices can only be convex
- if (vertexCount <= 3) return true;
-
- // All angles in the polygon computed will have the same direction sign if the polygon is convex
- int flag = 0;
- for (int i = 0; i < vertexCount; i++) {
- // Determine the next two vertecies to check
- int j = (i + 1) % vertexCount;
- int k = (i + 2) % vertexCount;
-
- // Calculate the cross product of the three vertecies
- int cross = crossProduct(vertices[i], vertices[j], vertices[k]);
-
- // The lower two bits of the flag represent the following:
- // 0: negative angle occurred
- // 1: positive angle occurred
-
- // The sign of the current angle is recorded in Flag
- if (cross < 0)
- flag |= 1;
- else if (cross > 0)
- flag |= 2;
-
- // If flag is 3, there are both positive and negative angles; so the polygon is concave
- if (flag == 3)
- return false;
- }
-
- // Polygon is convex
- return true;
-}
-
// Make a determine vertex order
// -----------------------------
@@ -199,12 +148,6 @@ void Polygon::ensureCWOrder() {
if (!isCW())
reverseVertexOrder();
}
-
-void Polygon::ensureCCWOrder() {
- if (!isCCW())
- reverseVertexOrder();
-}
-
// Reverse the order of vertecies
// ------------------------------
@@ -227,15 +170,6 @@ int Polygon::crossProduct(const Vertex &v1, const Vertex &v2, const Vertex &v3)
return (v2.x - v1.x) * (v3.y - v2.y) -
(v2.y - v1.y) * (v3.x - v2.x);
}
-
-// Scalar Product
-// --------------
-
-int Polygon::dotProduct(const Vertex &v1, const Vertex &v2, const Vertex &v3) const {
- return (v1.x - v2.x) * (v3.x - v2.x) +
- (v1.y - v2.y) * (v3.x - v2.y);
-}
-
// Check for self-intersections
// ----------------------------
diff --git a/engines/sword25/math/polygon.h b/engines/sword25/math/polygon.h
index 1b2a0b191c..4bb28f827a 100644
--- a/engines/sword25/math/polygon.h
+++ b/engines/sword25/math/polygon.h
@@ -114,20 +114,6 @@ public:
bool isCCW() const;
/**
- * Checks whether the polygon is convex.
- * @return Returns true if the polygon is convex. Returns false if the polygon is concave.
- * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
- */
- bool isConvex() const;
-
- /**
- * Checks whether the polygon is concave.
- * @return Returns true if the polygon is concave. Returns false if the polygon is convex.
- * @remark This method only returns a meaningful result if the polygon has at least three Vertecies.
- */
- bool isConcave() const;
-
- /**
* Checks whether a point is inside the polygon
* @param Vertex A Vertex with the co-ordinates of the point to be tested.
* @param BorderBelongsToPolygon Specifies whether the edge of the polygon should be considered
@@ -200,7 +186,6 @@ public:
private:
bool _isCW;
- bool _isConvex;
Vertex _centroid;
/**
@@ -216,12 +201,6 @@ private:
bool computeIsCW() const;
/**
- * Determines whether the polygon is convex or concave.
- * @return Returns true if the polygon is convex, otherwise false.
- */
- bool computeIsConvex() const;
-
- /**
* Calculates the cross product of three Vertecies
* @param V1 The first Vertex
* @param V2 The second Vertex
@@ -232,19 +211,6 @@ private:
int crossProduct(const Vertex &v1, const Vertex &v2, const Vertex &v3) const;
/**
- * Computes the scalar product of two vectors spanning three vertecies
- *
- * The vectors are spanned by V2->V1 and V2->V3
- *
- * @param V1 The first Vertex
- * @param V2 The second Vertex
- * @param V3 The third Vertex
- * @return Returns the dot product of the three Vertecies.
- * @todo This method would be better as a method of the BS_Vertex class
- */
- int dotProduct(const Vertex &v1, const Vertex &v2, const Vertex &v3) const;
-
- /**
* Checks whether the polygon is self-intersecting
* @return Returns true if the polygon is self-intersecting.
* Returns false if the polygon is not self-intersecting.