Regular (non-periodic) loft form curves.
(
*curves: Curve,
order: int = 3,
lam: float = 1e-9,
penalty: int = 4,
tangents: Optional[List[Tuple[Array, Array]]] = None,
)
| 2062 | |
| 2063 | |
| 2064 | def loft( |
| 2065 | *curves: Curve, |
| 2066 | order: int = 3, |
| 2067 | lam: float = 1e-9, |
| 2068 | penalty: int = 4, |
| 2069 | tangents: Optional[List[Tuple[Array, Array]]] = None, |
| 2070 | ) -> Surface: |
| 2071 | """ |
| 2072 | Regular (non-periodic) loft form curves. |
| 2073 | """ |
| 2074 | |
| 2075 | nknots: int = len(curves) |
| 2076 | |
| 2077 | # collect control pts |
| 2078 | pts = np.stack([c.pts for c in curves]) |
| 2079 | |
| 2080 | # approximate |
| 2081 | pts_new = [] |
| 2082 | |
| 2083 | for j in range(pts.shape[1]): |
| 2084 | pts_new.append( |
| 2085 | approximate( |
| 2086 | pts[:, j, :], |
| 2087 | knots=nknots, |
| 2088 | order=order, |
| 2089 | lam=lam, |
| 2090 | penalty=penalty, |
| 2091 | tangents=tangents[j] if tangents else None, |
| 2092 | ).pts |
| 2093 | ) |
| 2094 | |
| 2095 | # construct the final surface |
| 2096 | rv = Surface( |
| 2097 | np.stack(pts_new).swapaxes(0, 1), |
| 2098 | np.concatenate( |
| 2099 | (np.repeat(0, order), linspace(0, 1, nknots), np.repeat(1, order)) |
| 2100 | ), |
| 2101 | curves[0].knots, |
| 2102 | order, |
| 2103 | curves[0].order, |
| 2104 | False, |
| 2105 | curves[0].periodic, |
| 2106 | ) |
| 2107 | |
| 2108 | return rv |