Refactoring

This commit is contained in:
Isaac
2024-05-18 18:25:36 +04:00
parent c034abeca8
commit 6188ec971c
2 changed files with 15 additions and 15 deletions

View File

@@ -35,7 +35,7 @@ float interpolate(float value, float to, float amount);
Vector1D interpolate(
Vector1D const &from,
Vector1D const &to,
double amount
float amount
);
struct __attribute__((packed)) Vector2D {
@@ -100,23 +100,23 @@ struct __attribute__((packed)) Vector2D {
Vector2D pointOnPath(Vector2D const &to, Vector2D const &outTangent, Vector2D const &inTangent, double amount) const;
Vector2D interpolate(Vector2D const &to, double amount) const;
Vector2D interpolate(Vector2D const &to, float amount) const;
Vector2D interpolate(
Vector2D const &to,
Vector2D const &outTangent,
Vector2D const &inTangent,
double amount,
float amount,
int maxIterations = 3,
int samples = 20,
double accuracy = 1.0
float accuracy = 1.0
) const;
};
Vector2D interpolate(
Vector2D const &from,
Vector2D const &to,
double amount
float amount
);
struct Vector3D {
@@ -137,7 +137,7 @@ struct Vector3D {
Vector3D interpolate(
Vector3D const &from,
Vector3D const &to,
double amount
float amount
);
inline double degreesToRadians(double value) {

View File

@@ -154,7 +154,7 @@ float interpolate(float value, float to, float amount) {
Vector1D interpolate(
Vector1D const &from,
Vector1D const &to,
double amount
float amount
) {
return Vector1D(interpolate(from.value, to.value, amount));
}
@@ -162,7 +162,7 @@ Vector1D interpolate(
Vector2D interpolate(
Vector2D const &from,
Vector2D const &to,
double amount
float amount
) {
return Vector2D(interpolate(from.x, to.x, amount), interpolate(from.y, to.y, amount));
}
@@ -171,7 +171,7 @@ Vector2D interpolate(
Vector3D interpolate(
Vector3D const &from,
Vector3D const &to,
double amount
float amount
) {
return Vector3D(interpolate(from.x, to.x, amount), interpolate(from.y, to.y, amount), interpolate(from.z, to.z, amount));
}
@@ -289,7 +289,7 @@ struct InterpolationPoint2D {
};
namespace {
double interpolateDouble(double value, double to, double amount) {
double interpolateFloat(float value, float to, float amount) {
return value + ((to - value) * amount);
}
}
@@ -304,10 +304,10 @@ Vector2D Vector2D::pointOnPath(Vector2D const &to, Vector2D const &outTangent, V
return f;
}
Vector2D Vector2D::interpolate(Vector2D const &to, double amount) const {
Vector2D Vector2D::interpolate(Vector2D const &to, float amount) const {
return Vector2D(
interpolateDouble(x, to.x, amount),
interpolateDouble(y, to.y, amount)
interpolateFloat(x, to.x, amount),
interpolateFloat(y, to.y, amount)
);
}
@@ -315,10 +315,10 @@ Vector2D Vector2D::interpolate(
Vector2D const &to,
Vector2D const &outTangent,
Vector2D const &inTangent,
double amount,
float amount,
int maxIterations,
int samples,
double accuracy
float accuracy
) const {
if (amount == 0.0) {
return *this;