Rename bezier functions

This commit is contained in:
Pyro Nicampt committed 2024-12-23 03:57:14 -06:00
1 parent 8a0fba67e1
commit e843ac2004
2 files changed
+6 -6

No files matched your search

+2 -2
View File
@@ -210,10 +210,10 @@ function drawTracks(bezierData){
let genPath = 'M '; let genPath = 'M ';
genPath += `${bezStart.x} ${bezStart.z} `; genPath += `${bezStart.x} ${bezStart.z} `;
genPath += `C ${bezHandle1.x} ${bezHandle1.z} ${bezHandle2.x} ${bezHandle2.z} ${bezEnd.x} ${bezEnd.z} `; genPath += `C ${bezHandle1.x} ${bezHandle1.z} ${bezHandle2.x} ${bezHandle2.z} ${bezEnd.x} ${bezEnd.z} `;
let grade = Bezier.estimateMaxGrade(bezStart, bezHandle1, bezHandle2, bezEnd, bezierGradeResolution); let grade = Bezier.estimateGrade(bezStart, bezHandle1, bezHandle2, bezEnd, bezierGradeResolution);
let gradeClass = Utils.gradeToClass(grade); let gradeClass = Utils.gradeToClass(grade);
let length = Bezier.estimateLength(bezStart, bezHandle1, bezHandle2, bezEnd, bezierLengthResolution); let length = Bezier.estimateLength(bezStart, bezHandle1, bezHandle2, bezEnd, bezierLengthResolution);
let curvature = Bezier.estimateMaxCurvature(bezStart, bezHandle1, bezHandle2, bezEnd, bezierCurvatureResolution); let curvature = Bezier.estimateCurvature(bezStart, bezHandle1, bezHandle2, bezEnd, bezierCurvatureResolution);
newBezier.setAttribute('d', genPath); newBezier.setAttribute('d', genPath);
newBezier.classList.add('rail'); newBezier.classList.add('rail');
+4 -4
View File
@@ -7,7 +7,7 @@ import * as Vector from './vectorlib.js';
* @property {number} z * @property {number} z
*/ */
/** Estimate the maximum grade of the bezier. /** Estimate the grade of the bezier.
* @param {Vector} p1 - Start * @param {Vector} p1 - Start
* @param {Vector} h1 - Handle 1 * @param {Vector} h1 - Handle 1
* @param {Vector} h2 - Handle 2 * @param {Vector} h2 - Handle 2
@@ -15,7 +15,7 @@ import * as Vector from './vectorlib.js';
* @param {number} iterationCount - How many steps along the bezier to check * @param {number} iterationCount - How many steps along the bezier to check
* @returns {number} Grade as a decimal * @returns {number} Grade as a decimal
*/ */
export function estimateMaxGrade(p1, h1, h2, p2, iterationCount = 50){ export function estimateGrade(p1, h1, h2, p2, iterationCount = 50){
let grade = 0; let grade = 0;
let totalGrade = 0; let totalGrade = 0;
for(let i=0; i<=iterationCount; i++){ for(let i=0; i<=iterationCount; i++){
@@ -47,7 +47,7 @@ export function estimateLength(p1, h1, h2, p2, iterationCount = 50){
return length; return length;
} }
/** Estimate the maximum 3D curvature of the bezier. /** Estimate the 3D curvature of the bezier.
* @param {Vector} p1 - Start * @param {Vector} p1 - Start
* @param {Vector} h1 - Handle 1 * @param {Vector} h1 - Handle 1
* @param {Vector} h2 - Handle 2 * @param {Vector} h2 - Handle 2
@@ -55,7 +55,7 @@ export function estimateLength(p1, h1, h2, p2, iterationCount = 50){
* @param {number} iterationCount - How many steps along the bezier to check * @param {number} iterationCount - How many steps along the bezier to check
* @returns {number} Curvature, take `1/curvature` to get radius. * @returns {number} Curvature, take `1/curvature` to get radius.
*/ */
export function estimateMaxCurvature(p1, h1, h2, p2, iterationCount = 50){ export function estimateCurvature(p1, h1, h2, p2, iterationCount = 50){
let curvature = 0; let curvature = 0;
let t = 0; let t = 0;
let vel = {}; let vel = {};