psychopy.tools.mathtools.vertexNormal

psychopy.tools.mathtools.vertexNormal(faceNorms, norm=True, out=None, dtype=None)[source]

Compute a vertex normal from shared triangles.

This function computes a vertex normal by averaging the surface normals of the triangles it belongs to. If model has no vertex normals, first use surfaceNormal() to compute them, then run vertexNormal() to compute vertex normal attributes.

While this function is mainly used to compute vertex normals, it can also be supplied triangle tangents and bitangents.

Parameters
  • faceNorms (array_like) – An array (Nx3) of surface normals.

  • norm (bool, optional) – Normalize computed normals if True, default is True.

  • out (ndarray, optional) – Optional output array.

  • dtype (dtype or str, optional) – Data type for computations can either be ‘float32’ or ‘float64’. If out is specified, the data type of out is used and this argument is ignored. If out is not provided, ‘float64’ is used by default.

Returns

Vertex normal.

Return type

ndarray

Examples

Compute a vertex normal from the face normals of the triangles it belongs to:

normals = [[1., 0., 0.], [0., 1., 0.]]  # adjacent face normals
vertexNorm = vertexNormal(normals)

Back to top