Py5Shape.get_normal_x()

Py5Shape.get_normal_x()

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

Examples

example picture for get_normal_x()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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_x(i), s1.get_normal_y(i), s1.get_normal_z(i))

    py5.shape(s1, 50, 50)

Description

Get the normal vector’s x value 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.getNormalX

Syntax

get_normal_x(index: int, /) -> float

Parameters

  • index: int - vertex index

Updated on November 12, 2021 11:30:58am UTC