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

Method normalAt

cadquery/occ_impl/shapes.py:3395–3422  ·  view source on GitHub ↗

Computes the normal vector at the desired location on the face. :returns: a vector representing the direction :param locationVector: the location to compute the normal at. If none, the center of the face is used. :type locationVector: a vector that lies on the surfa

(self, locationVector: VectorLike | None = None)

Source from the content-addressed store, hash-verified

3393
3394 @multimethod
3395 def normalAt(self, locationVector: VectorLike | None = None) -> Vector:
3396 """
3397 Computes the normal vector at the desired location on the face.
3398
3399 :returns: a vector representing the direction
3400 :param locationVector: the location to compute the normal at. If none, the center of the face is used.
3401 :type locationVector: a vector that lies on the surface.
3402 """
3403 # get the geometry
3404 surface = self._geomAdaptor()
3405
3406 if locationVector is None:
3407 u0, u1, v0, v1 = self._uvBounds()
3408 u = 0.5 * (u0 + u1)
3409 v = 0.5 * (v0 + v1)
3410 else:
3411 # project point on surface
3412 projector = GeomAPI_ProjectPointOnSurf(
3413 Vector(locationVector).toPnt(), surface
3414 )
3415
3416 u, v = projector.LowerDistanceParameters()
3417
3418 p = gp_Pnt()
3419 vn = gp_Vec()
3420 BRepGProp_Face(self.wrapped).Normal(u, v, p, vn)
3421
3422 return Vector(vn).normalized()
3423
3424 @multimethod
3425 def normalAt(self, u: Real, v: Real) -> tuple[Vector, Vector]:

Callers 15

filterMethod · 0.45
_isCoPlanarMethod · 0.45
workplaneMethod · 0.45
mirrorMethod · 0.45
_getAxisMethod · 0.45
_getPlnMethod · 0.45
extrudeLinearMethod · 0.45
makeTextMethod · 0.45
textFunction · 0.45
prismFunction · 0.45
draftFunction · 0.45

Calls 5

_geomAdaptorMethod · 0.95
_uvBoundsMethod · 0.95
VectorClass · 0.85
toPntMethod · 0.80
normalizedMethod · 0.80

Tested by 11

test_normalsFunction · 0.36
test_reverseFunction · 0.36
testSweepMethod · 0.36
testMultisectionSweepMethod · 0.36
testFaceToPlnMethod · 0.36
testBaseDirSelectorMethod · 0.36
testNthDistanceMethod · 0.36
test_textFunction · 0.36