-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 281bd5e
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include "bezier_core.h" | ||
|
||
double linear(const double t, const double p0, const double p1) { | ||
return p0 + (p1 - p0) * t; | ||
} | ||
|
||
double quadratic(const double t, const double p0, const double p1, const double p2) { | ||
const double at = 1 - t; | ||
return | ||
at * at * p0 + | ||
2 * at * t * p1 + | ||
t * t * p2; | ||
} | ||
|
||
double cubic(const double t, const double p0, const double p1, const double p2, const double p3) { | ||
const double at = 1 - t; | ||
return | ||
at * at * at * p0 + | ||
3 * at * at * t * p1 + | ||
3 * at * t * t * p2 + | ||
t * t * t * p3; | ||
} | ||
|
||
float linearf(const float t, const float p0, const float p1) { | ||
return p0 + (p1 - p0) * t; | ||
} | ||
|
||
float quadraticf(const float t, const float p0, const float p1, const float p2) { | ||
const float at = 1 - t; | ||
return | ||
at * at * p0 + | ||
2 * at * t * p1 + | ||
t * t * p2; | ||
} | ||
|
||
float cubicf(const float t, const float p0, const float p1, const float p2, const float p3) { | ||
const float at = 1 - t; | ||
return | ||
at * at * at * p0 + | ||
3 * at * at * t * p1 + | ||
3 * at * t * t * p2 + | ||
t * t * t * p3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef __HMAH_BEZIER_CORE_H__ | ||
#define __HMAH_BEZIER_CORE_H__ | ||
|
||
double linear(double t, double p0, double p1); | ||
double quadratic(double t, double p0, double p1, double p2); | ||
double cubic(double t, double p0, double p1, double p2, double p3); | ||
|
||
float linearf(float t, float p0, float p1); | ||
float quadraticf(float t, float p0, float p1, float p2); | ||
float cubicf(float t, float p0, float p1, float p2, float p3); | ||
|
||
#endif // __HMAH_BEZIER_CORE_H__ |