16 lines
482 B
TypeScript
16 lines
482 B
TypeScript
export module Bezier {
|
|
|
|
export function GetPoint(p0: cc.Vec2, p1: cc.Vec2, p2: cc.Vec2, p3: cc.Vec2, t: number): cc.Vec2 {
|
|
if (t < 0) {
|
|
t = 0;
|
|
}
|
|
else if (t > 1) {
|
|
t = 1
|
|
}
|
|
let OneMinusT = 1 - t;
|
|
return p0.mul(OneMinusT * OneMinusT * OneMinusT)
|
|
.add(p1.mul(3 * OneMinusT * OneMinusT * t))
|
|
.add(p2.mul(3 * OneMinusT * t * t))
|
|
.add(p3.mul(t * t * t));
|
|
}
|
|
} |