Clean up love’s internal Vector code a bit, and rename it to Vector2 so it’s more obvious what it is.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-05-16 22:07:01 -03:00
parent 135d928922
commit ac697ddb0f
25 changed files with 486 additions and 384 deletions
+11 -11
View File
@@ -40,7 +40,7 @@ public:
/**
* @param controlPoints Control polygon of the curve.
**/
BezierCurve(const std::vector<Vector> &controlPoints);
BezierCurve(const std::vector<Vector2> &controlPoints);
/**
* @returns Degree of the curve
@@ -58,14 +58,14 @@ public:
/**
* @returns i'th control point.
**/
const Vector &getControlPoint(int i) const;
const Vector2 &getControlPoint(int i) const;
/**
* Sets the i'th control point.
* @param i Control point to change.
* @param point New control point.
**/
void setControlPoint(int i, const Vector &point);
void setControlPoint(int i, const Vector2 &point);
/**
* Insert a new control point before the i'th control point.
@@ -73,7 +73,7 @@ public:
* @param point Control point to insert.
* @param pos Position to insert.
**/
void insertControlPoint(const Vector &point, int pos = -1);
void insertControlPoint(const Vector2 &point, int pos = -1);
/**
* Remove the i'th control point from the curve.
@@ -93,27 +93,27 @@ public:
* Move the curve.
* @param t Translation vector.
*/
void translate(const Vector &t);
void translate(const Vector2 &t);
/**
* Rotate the curve.
* @param phi Rotation angle (radians).
* @param center Rotation center.
*/
void rotate(double phi, const Vector &center);
void rotate(double phi, const Vector2 &center);
/**
* Scale the curve.
* @param phi Scale factor.
* @param center Scale center.
*/
void scale(double phi, const Vector &center);
void scale(double phi, const Vector2 &center);
/**
* Evaluates the curve at time t.
* @param t Curve parameter, must satisfy 0 <= t <= 1.
**/
Vector evaluate(double t) const;
Vector2 evaluate(double t) const;
/**
* Get curve segment starting at t1 and ending at t2.
@@ -129,7 +129,7 @@ public:
* @param accuracy The 'fineness' of the curve.
* @returns A polygon chain that approximates the bezier curve.
**/
std::vector<Vector> render(int accuracy = 4) const;
std::vector<Vector2> render(int accuracy = 4) const;
/**
* Renders a segment of the curve by subdivision.
@@ -138,10 +138,10 @@ public:
* @param accuracy The 'fineness' of the curve.
* @returns A polygon chain that approximates the segment along the curve
**/
std::vector<Vector> renderSegment(double start, double end, int accuracy = 4) const;
std::vector<Vector2> renderSegment(double start, double end, int accuracy = 4) const;
private:
std::vector<Vector> controlPoints;
std::vector<Vector2> controlPoints;
};
}