MCPcopy
hub / github.com/CadQuery/cadquery / splineApprox

Method splineApprox

cadquery/cq.py:1893–1937  ·  view source on GitHub ↗

Create a spline interpolated through the provided points (2D or 3D). :param points: points to interpolate through :param tol: tolerance of the algorithm (default: 1e-6) :param minDeg: minimum spline degree (default: 1) :param maxDeg: maximum spline degree (d

(
        self: T,
        points: Iterable[VectorLike],
        tol: Optional[float] = 1e-6,
        minDeg: int = 1,
        maxDeg: int = 6,
        smoothing: Optional[Tuple[float, float, float]] = (1, 1, 1),
        forConstruction: bool = False,
        includeCurrent: bool = False,
        makeWire: bool = False,
    )

Source from the content-addressed store, hash-verified

1891 return self.newObject([rv_w if makeWire else e])
1892
1893 def splineApprox(
1894 self: T,
1895 points: Iterable[VectorLike],
1896 tol: Optional[float] = 1e-6,
1897 minDeg: int = 1,
1898 maxDeg: int = 6,
1899 smoothing: Optional[Tuple[float, float, float]] = (1, 1, 1),
1900 forConstruction: bool = False,
1901 includeCurrent: bool = False,
1902 makeWire: bool = False,
1903 ) -> T:
1904 """
1905 Create a spline interpolated through the provided points (2D or 3D).
1906
1907 :param points: points to interpolate through
1908 :param tol: tolerance of the algorithm (default: 1e-6)
1909 :param minDeg: minimum spline degree (default: 1)
1910 :param maxDeg: maximum spline degree (default: 6)
1911 :param smoothing: optional parameters for the variational smoothing algorithm (default: (1,1,1))
1912 :param includeCurrent: use current point as a starting point of the curve
1913 :param makeWire: convert the resulting spline edge to a wire
1914 :return: a Workplane object with the current point at the end of the spline
1915
1916 *WARNING* for advanced users.
1917 """
1918
1919 allPoints = self._toVectors(points, includeCurrent)
1920
1921 e = Edge.makeSplineApprox(
1922 allPoints,
1923 minDeg=minDeg,
1924 maxDeg=maxDeg,
1925 smoothing=smoothing,
1926 **({"tol": tol} if tol else {}),
1927 )
1928
1929 if makeWire:
1930 rv_w = Wire.assembleEdges([e])
1931 if not forConstruction:
1932 self._addPendingWire(rv_w)
1933 else:
1934 if not forConstruction:
1935 self._addPendingEdge(e)
1936
1937 return self.newObject([rv_w if makeWire else e])
1938
1939 def parametricCurve(
1940 self: T,

Callers 1

testSplineApproxMethod · 0.80

Calls 6

_toVectorsMethod · 0.95
_addPendingWireMethod · 0.95
_addPendingEdgeMethod · 0.95
newObjectMethod · 0.95
assembleEdgesMethod · 0.80
makeSplineApproxMethod · 0.45

Tested by 1

testSplineApproxMethod · 0.64