Sample a curve based on a number of points or deflection. :param n: Number of positions or deflection :return: A list of Vectors and a list of parameters.
(
self: Mixin1DProtocol, n: int | float
)
| 2383 | return [self.positionAt(d, mode) for d in ds] |
| 2384 | |
| 2385 | def sample( |
| 2386 | self: Mixin1DProtocol, n: int | float |
| 2387 | ) -> tuple[list[Vector], list[float]]: |
| 2388 | """ |
| 2389 | Sample a curve based on a number of points or deflection. |
| 2390 | |
| 2391 | :param n: Number of positions or deflection |
| 2392 | :return: A list of Vectors and a list of parameters. |
| 2393 | """ |
| 2394 | |
| 2395 | gcpnts: GCPnts_QuasiUniformAbscissa | GCPnts_QuasiUniformDeflection |
| 2396 | |
| 2397 | if isinstance(n, int): |
| 2398 | crv = self._geomAdaptor() |
| 2399 | gcpnts = GCPnts_QuasiUniformAbscissa(crv, n + 1 if crv.IsClosed() else n) |
| 2400 | else: |
| 2401 | crv = self._geomAdaptor() |
| 2402 | gcpnts = GCPnts_QuasiUniformDeflection(crv, n) |
| 2403 | |
| 2404 | N_pts = gcpnts.NbPoints() |
| 2405 | |
| 2406 | params = [ |
| 2407 | gcpnts.Parameter(i) |
| 2408 | for i in range(1, N_pts if crv.IsClosed() else N_pts + 1) |
| 2409 | ] |
| 2410 | pnts = [Vector(crv.Value(p)) for p in params] |
| 2411 | |
| 2412 | return pnts, params |
| 2413 | |
| 2414 | def locationAt( |
| 2415 | self: Mixin1DProtocol, |