-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Feature Request: Add Quartic Bézier Curves (with Three Manipulation Points) to Autodrive Course Editor
Summary
Currently, Autodrive Course Editor supports cubic Bézier curves, which offer two control points to manipulate curvature between two fixed endpoints. This feature request proposes adding quartic Bézier curves, allowing three control points while still maintaining two fixed endpoints. This additional control point can enable more precise path shaping and smoother transitions in complex course designs.
Rationale
-
Increased Flexibility
- A quartic Bézier curve has two endpoints and three control points, providing more fine-grained control over curvature compared to a cubic Bézier curve (which has only two control points).
- Users can create more complex shapes and smoother transitions for intricate course layouts.
-
User Demand
- Some course designs require delicate shaping that is cumbersome with only two control points.
- Advanced users, especially those editing large or detailed maps, would benefit from having an extra control point to eliminate the need for multiple small cubic segments.
-
Consistency with Existing Workflow
- The interface for adding control points is already established for cubic curves (two control points).
- Adding a quartic option extends the same principle, with one additional control point for users to manipulate.
Proposed Implementation
-
UI Changes
- Add a “Curve Type” dropdown or toggle in the existing editor:
- Cubic Bézier (Default) – 2 control points
- Quartic Bézier (Proposed) – 3 control points
- When “Quartic Bézier” is selected, an additional control point handle appears on the curve.
- Add a “Curve Type” dropdown or toggle in the existing editor:
-
Data Structure
- Store the quartic Bézier curve as five points:
- P0 (start), P1, P2, P3, P4 (end).
- The editor should serialize and deserialize these five points in the same manner as the current cubic implementation (just with one extra control point).
- Store the quartic Bézier curve as five points:
-
Rendering Logic
- A quartic Bézier function can be integrated similarly to the cubic one. For example, the parametric form for a quartic Bézier curve ( B(t) ) with control points ( P_0, P_1, P_2, P_3, P_4 ) is:
[
B(t) = (1 - t)^4 P_0 + 4(1 - t)^3 t P_1 + 6(1 - t)^2 t^2 P_2 + 4(1 - t) t^3 P_3 + t^4 P_4,\quad t \in [0,1]
] - A simple approach is to sample points along the curve (e.g., in increments of 0.01) and draw line segments between them.
- A quartic Bézier function can be integrated similarly to the cubic one. For example, the parametric form for a quartic Bézier curve ( B(t) ) with control points ( P_0, P_1, P_2, P_3, P_4 ) is:
-
Example Pseudocode
// quarticBezier(t, P0, P1, P2, P3, P4) // t ranges from 0 to 1 double x = Math.pow(1 - t, 4) * P0.x + 4 * Math.pow(1 - t, 3) * t * P1.x + 6 * Math.pow(1 - t, 2) * Math.pow(t, 2) * P2.x + 4 * (1 - t) * Math.pow(t, 3) * P3.x + Math.pow(t, 4) * P4.x; double y = Math.pow(1 - t, 4) * P0.y + 4 * Math.pow(1 - t, 3) * t * P1.y + 6 * Math.pow(1 - t, 2) * Math.pow(t, 2) * P2.y + 4 * (1 - t) * Math.pow(t, 3) * P3.y + Math.pow(t, 4) * P4.y; // Connect these points as you iterate t from 0 to 1
-
Backward Compatibility
- Existing cubic curves would remain fully functional.
- Only when the user explicitly selects “Quartic Bézier” would the new logic and data structures be used.
- Projects saved with quartic curves should still open in versions that support quartic.
- If backward compatibility is needed for older editor versions, it could either:
- Fallback to a cubic approximation, or
- Indicate that some features may not be available in older versions.
Benefits
- Enhanced Editing Power: Users gain more direct control over shape and smoothness.
- Reduced Complexity: Fewer segments might be needed for detailed course designs, reducing the total number of curves.
- Familiar Workflow: Maintains the same drag-and-drop control point paradigm; just one extra handle for quartic curves.
Thank you for considering this feature request!
Implementing quartic Bézier curves in Autodrive Course Editor would greatly expand the tool’s flexibility for detailed course designs, while staying consistent with the existing cubic Bézier approach.