Replies: 4 comments 7 replies
-
You will always have issues this problem when using any bezier curve because they aren't designed this way. Instead https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline is needed and is much more complex but 100% solves the problem. I'm looking around at OpenCascade to see if it has one. https://dev.opencascade.org/doc/refman/html/search.php?query=spline+-bspline is the query I used. "Wilson-Fowler" (Spline type 4) seems to be functional equivalent to Catmull rom... https://dev.opencascade.org/doc/refman/html/class_i_g_e_s_geom___spline_curve.html |
Beta Was this translation helpful? Give feedback.
-
Note that I have made the All this said, I will provide a |
Beta Was this translation helpful? Give feedback.
-
I have to correct myself: adding more points is certainly not an easy solution to create a better curve with drawPointsInterpolation. If you add too many points and these are not accurate, the curve "goes crazy". |
Beta Was this translation helpful? Give feedback.
-
The The code is: // Replicad code to draw an airfoil shape
// Purpose: demonstrate how to draw an airfoil
// airfoil design from https://www.flusur.com/airfoil-design/
function main(
{ drawPointsInterpolation }) // functions used within the main program
{
// the following array of points was created from a
// standard airfoil coordinate data file
// the airfoil coordinate file is normalised to a standard chord of 1
let airfoilPoints=
[[1.0000000 ,0.0000000],
[0.9985383 ,0.0003261],
[0.9943357 ,0.0012896],
[0.9874835 ,0.0028991],
[0.9780353 ,0.0051591],
[0.9660390 ,0.0080639],
[0.9515443 ,0.0115947],
[0.9346057 ,0.0157195],
[0.9152843 ,0.0203926],
[0.8936495 ,0.0255547],
[0.8697794 ,0.0311333],
[0.8437625 ,0.0370433],
[0.8156986 ,0.0431884],
[0.7857000 ,0.0494617],
[0.7538929 ,0.0557483],
[0.7204180 ,0.0619265],
[0.6854321 ,0.0678706],
[0.6491079 ,0.0734536],
[0.6116358 ,0.0785498],
[0.5732228 ,0.0830380],
[0.5340930 ,0.0868053],
[0.4944863 ,0.0897496],
[0.4546574 ,0.0917838],
[0.4148737 ,0.0928383],
[0.3754127 ,0.0928639],
[0.3365591 ,0.0918344],
[0.2986011 ,0.0897478],
[0.2618267 ,0.0866279],
[0.2265198 ,0.0825240],
[0.1929555 ,0.0775104],
[0.1613969 ,0.0716848],
[0.1320908 ,0.0651660],
[0.1052651 ,0.0580905],
[0.0811259 ,0.0506086],
[0.0598565 ,0.0428803],
[0.0416163 ,0.0350696],
[0.0265420 ,0.0273396],
[0.0147495 ,0.0198457],
[0.0063383 ,0.0127275],
[0.0013965 ,0.0060949],
[0.0000000 ,0.0000000],
[0.0025589 ,-0.0060606],
[0.0092026 ,-0.0115698],
[0.0196689 ,-0.0165551],
[0.0336781 ,-0.0209976],
[0.0509521 ,-0.0248665],
[0.0712157 ,-0.0281356],
[0.0941973 ,-0.0307883],
[0.1196300 ,-0.0328200],
[0.1472530 ,-0.0342383],
[0.1768128 ,-0.0350618],
[0.2080639 ,-0.0353198],
[0.2407701 ,-0.0350502],
[0.2747044 ,-0.0342981],
[0.3096492 ,-0.0331148],
[0.3453962 ,-0.0315557],
[0.3817458 ,-0.0296795],
[0.4185066 ,-0.0275463],
[0.4554945 ,-0.0252170],
[0.4925323 ,-0.0227516],
[0.5294482 ,-0.0202088],
[0.5660754 ,-0.0176447],
[0.6022513 ,-0.0151121],
[0.6378161 ,-0.0126595],
[0.6726125 ,-0.0103308],
[0.7064852 ,-0.0081646],
[0.7392796 ,-0.0061931],
[0.7708424 ,-0.0044425],
[0.8010203 ,-0.0029317],
[0.8296603 ,-0.0016722],
[0.8566098 ,-0.0006682],
[0.8817164 ,0.0000844],
[0.9048280 ,0.0005973],
[0.9257939 ,0.0008906],
[0.9444642 ,0.0009917],
[0.9606910 ,0.0009361],
[0.9743280 ,0.0007659],
[0.9852307 ,0.0005300],
[0.9932535 ,0.0002828],
[0.9982433 ,0.0000842],
[1.0000000 ,0.0000000]]
// scale chord length
let chord = 100
let span = 100
let airfoilPointsLarge = airfoilPoints.map(function([x,y]){return [x*chord,y*chord]})
let airfoil = drawPointsInterpolation(airfoilPointsLarge).sketchOnPlane("XZ");
let wing = airfoil.extrude(span)
return [wing]
} |
Beta Was this translation helpful? Give feedback.
-
Today I tried to model a hook for Apple Earpods. These hooks, published on Thingiverse by Tom Lombardi (see https://www.thingiverse.com/thing:153374), are very practical to keep them fixed to your ears while running.
While modelling the curve needed to create these hooks, I tried several methods. Perhaps it is helpful for others as well to understand the difference between the methods to create curves.
I started with drawing the rough shape of the curve.
From this sketch I derived some "throughPoints" for the curve. The following code shows the result of some experiments to create a curve through these points. I found the following:
Using
smoothSplineTo
requires the least amount of commands but results in a very strange curve. Obviously the tangents at the beginning and the end of the curve are not related to any other point in the curve but are set to 0 degrees. Therefore it is almost obligatory to add a configuration statement such as{startTangent:180,endTangent:125}
. Still the resulting curve is difficult to control and does not look very smooth;The
bezierCurve
results in a nice smooth curve overall, but as all points except for the last point are used only as control points, a lot of trial and error is needed to adjust these points to find the correct curve.But the control points are really very weird to arrive at this shape:
With a
quadraticBezierCurve
it is relatively easy to force the curve through thethroughPoints
. Only one control point has to be added per point to define the tangents. The downside is that it is not possible to influence both the tangent and the path of the curve.For this application, the
cubicBezierCurve
is the best option. The curve can be forced through thethroughPoints
and with the two control points per segment it is easy to adjust both the tangent and the shape of the curve.The code below contains all experiments. Using the Visualiser you can compare and adjust the shape of all curves.
Beta Was this translation helpful? Give feedback.
All reactions