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()
 1def setup():
 2    py5.size(100, 100, py5.P3D)
 3    py5.background(0)
 4    py5.directional_light(255, 255, 255, -1, -1, -1)
 5
 6    py5.sphere_detail(5)
 7    s1 = py5.create_shape(py5.SPHERE, 30)
 8
 9    for i in range(s1.get_vertex_count()):
10        py5.println(s1.get_normal_x(i), s1.get_normal_y(i), s1.get_normal_z(i))
11
12    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