Skip to content

Update BezierCurve2D.cs #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions BezierCurve2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private Vector3 CalculateQubicCurve3D(Vector3 pos0, Vector3 pos1, Vector3 pos2,
//2 points with TWO control Points means Qubic
// Mathematical Formula of Qubic Curves
//B(t) = (1-t)3P0 + 3(1-t)2tP1 + 3(1-t)t2P2 + t3P3 , 0 < t< 1
Vector3 res = ((1 - t) * (1 - t) * (1 - t) * pos0) + (3 * (1 - t) * (1 - t) * t * pos1) + (3 * (1 - t) * (1 - t) * t * pos2) + (t * t * t * pos3);
Vector3 res = ((1 - t) * (1 - t) * (1 - t) * pos0) + (3 * (1 - t) * (1 - t) * t * pos1) + (3 * (1 - t) * t * t * pos2) + (t * t * t * pos3);

return res;
}
Expand All @@ -42,9 +42,9 @@ private Vector2 CalculateQubicCurve2D(Vector3 pos0, Vector3 pos1, Vector3 pos2,
{
// Mathematical Formula of Qubic Curves
//B(t) = (1-t)3P0 + 3(1-t)2tP1 + 3(1-t)t2P2 + t3P3 , 0 < t< 1
Vector3 res = ((1 - t) * (1 - t) * (1 - t) * pos0) + (3 * (1 - t) * (1 - t) * t * pos1) + (3 * (1 - t) * (1 - t) * t * pos2) + (t * t * t * pos3);
Vector3 res = ((1 - t) * (1 - t) * (1 - t) * pos0) + (3 * (1 - t) * (1 - t) * t * pos1) + (3 * (1 - t) * t * t * pos2) + (t * t * t * pos3);

return new Vector2(res.x, res.y);
}
}
}
}