test for makeSplineApprox
This commit is contained in:
83
tests/naca.py
Executable file
83
tests/naca.py
Executable file
@ -0,0 +1,83 @@
|
||||
naca5305 = [
|
||||
[1.000074, 0.000520],
|
||||
[0.998545, 0.000829],
|
||||
[0.993968, 0.001750],
|
||||
[0.986369, 0.003267],
|
||||
[0.975792, 0.005351],
|
||||
[0.962301, 0.007964],
|
||||
[0.945974, 0.011059],
|
||||
[0.926909, 0.014580],
|
||||
[0.905218, 0.018465],
|
||||
[0.881032, 0.022648],
|
||||
[0.854494, 0.027058],
|
||||
[0.825764, 0.031621],
|
||||
[0.795017, 0.036263],
|
||||
[0.762437, 0.040911],
|
||||
[0.728224, 0.045493],
|
||||
[0.692585, 0.049938],
|
||||
[0.655739, 0.054180],
|
||||
[0.617912, 0.058158],
|
||||
[0.579336, 0.061813],
|
||||
[0.540252, 0.065095],
|
||||
[0.500900, 0.067958],
|
||||
[0.461525, 0.070367],
|
||||
[0.422374, 0.072291],
|
||||
[0.383692, 0.073709],
|
||||
[0.345722, 0.074611],
|
||||
[0.308702, 0.074992],
|
||||
[0.272257, 0.074521],
|
||||
[0.237079, 0.072481],
|
||||
[0.203612, 0.069020],
|
||||
[0.172090, 0.064350],
|
||||
[0.142727, 0.058704],
|
||||
[0.115719, 0.052328],
|
||||
[0.091240, 0.045475],
|
||||
[0.069442, 0.038397],
|
||||
[0.050454, 0.031335],
|
||||
[0.034383, 0.024516],
|
||||
[0.021313, 0.018141],
|
||||
[0.011308, 0.012382],
|
||||
[0.004410, 0.007379],
|
||||
[0.000639, 0.003232],
|
||||
[0.000000, 0.000000],
|
||||
[0.002443, -0.002207],
|
||||
[0.007902, -0.003318],
|
||||
[0.016322, -0.003385],
|
||||
[0.027630, -0.002492],
|
||||
[0.041737, -0.000752],
|
||||
[0.058539, 0.001696],
|
||||
[0.077918, 0.004691],
|
||||
[0.099743, 0.008055],
|
||||
[0.123875, 0.011591],
|
||||
[0.150167, 0.015098],
|
||||
[0.178462, 0.018365],
|
||||
[0.208603, 0.021185],
|
||||
[0.240422, 0.023351],
|
||||
[0.273752, 0.024670],
|
||||
[0.308614, 0.024992],
|
||||
[0.345261, 0.024967],
|
||||
[0.382862, 0.024875],
|
||||
[0.421191, 0.024682],
|
||||
[0.460016, 0.024358],
|
||||
[0.499100, 0.023878],
|
||||
[0.538207, 0.023226],
|
||||
[0.577098, 0.022390],
|
||||
[0.615534, 0.021370],
|
||||
[0.653278, 0.020171],
|
||||
[0.690099, 0.018807],
|
||||
[0.725767, 0.017298],
|
||||
[0.760061, 0.015670],
|
||||
[0.792768, 0.013955],
|
||||
[0.823684, 0.012188],
|
||||
[0.852613, 0.010407],
|
||||
[0.879374, 0.008651],
|
||||
[0.903799, 0.006957],
|
||||
[0.925731, 0.005364],
|
||||
[0.945032, 0.003906],
|
||||
[0.961578, 0.002615],
|
||||
[0.975264, 0.001519],
|
||||
[0.986001, 0.000641],
|
||||
[0.993720, 0.000001],
|
||||
[0.998372, -0.000389],
|
||||
[0.999926, -0.000520],
|
||||
]
|
||||
@ -4387,3 +4387,19 @@ class TestCadQuery(BaseTest):
|
||||
|
||||
with raises(ValueError):
|
||||
r.chamfer2D(0.25, [vs[0]])
|
||||
|
||||
def testSplineApprox(self):
|
||||
|
||||
from .naca import naca5305
|
||||
|
||||
pts = [Vector(e[0], e[1], 0) for e in naca5305]
|
||||
|
||||
e1 = Edge.makeSplineApprox(pts, 1e-6, maxDeg=6, smoothing=(1, 1, 1))
|
||||
e2 = Edge.makeSplineApprox(pts, 1e-6, minDeg=2, maxDeg=6)
|
||||
|
||||
self.assertTrue(e1.isValid())
|
||||
self.assertTrue(e2.isValid())
|
||||
self.assertTrue(e1.Length() > e2.Length())
|
||||
|
||||
with raises(ValueError):
|
||||
e4 = Edge.makeSplineApprox(pts, 1e-6, maxDeg=3, smoothing=(1, 1, 1.0))
|
||||
|
||||
Reference in New Issue
Block a user