Py5Shape.get_normal()#

Get the normal vector for one of a Py5Shape object’s vertices.

Examples#

example picture for get_normal()
def setup():
    py5.size(100, 100, py5.P3D)
    py5.background(0)
    py5.directional_light(255, 255, 255, -1, -1, -1)

    py5.sphere_detail(5)
    s1 = py5.create_shape(py5.SPHERE, 30)

    for i in range(s1.get_vertex_count()):
        py5.println(s1.get_normal(i))

    py5.shape(s1, 50, 50)

Description#

Get the normal vector for one of a Py5Shape object’s vertices. A normal vector is used for drawing three dimensional shapes and surfaces, and specifies a vector perpendicular to a shape’s surface which, in turn, determines how lighting affects it. Py5 attempts to automatically assign normals to shapes, and this method can be used to inspect that vector.

This method can only be used for a complete Py5Shape object, and never within a Py5Shape.begin_shape() and Py5Shape.end_shape() pair.

Underlying Processing method: PShape.getNormal

Signatures#

get_normal(
    index: int,  # vertex index
    /,
) -> Py5Vector

get_normal(
    index: int,  # vertex index
    vec: Py5Vector,  # target object to place vertex normal vector into
    /,
) -> Py5Vector

Updated on September 01, 2022 16:36:02pm UTC