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

Method normal

cadquery/occ_impl/shapes.py:2282–2308  ·  view source on GitHub ↗

Calculate the normal Vector. Only possible for planar curves. :return: normal vector

(self: Mixin1DProtocol)

Source from the content-addressed store, hash-verified

2280 return rv
2281
2282 def normal(self: Mixin1DProtocol) -> Vector:
2283 """
2284 Calculate the normal Vector. Only possible for planar curves.
2285
2286 :return: normal vector
2287 """
2288
2289 curve = self._geomAdaptor()
2290 gtype = self.geomType()
2291
2292 if gtype == "CIRCLE":
2293 circ = curve.Circle()
2294 rv = Vector(circ.Axis().Direction())
2295 elif gtype == "ELLIPSE":
2296 ell = curve.Ellipse()
2297 rv = Vector(ell.Axis().Direction())
2298 else:
2299 fs = BRepLib_FindSurface(self.wrapped, OnlyPlane=True)
2300 surf = fs.Surface()
2301
2302 if isinstance(surf, Geom_Plane):
2303 pln = surf.Pln()
2304 rv = Vector(pln.Axis().Direction())
2305 else:
2306 raise ValueError("Normal not defined")
2307
2308 return rv
2309
2310 def Center(self: Mixin1DProtocol) -> Vector:
2311

Callers

nothing calls this directly

Calls 3

VectorClass · 0.85
_geomAdaptorMethod · 0.45
geomTypeMethod · 0.45

Tested by

no test coverage detected