Skip to content

normalize_height_and_center

normalize_height_and_center(V, h, c, return_scale_trans=False)

Normalize the height of the mesh to h and center it at c.

Parameters:

Name Type Description Default
V numpy float array

Mesh vertices

required
h float

Desired height

required
c numpy float array

Desired center

required
return_scale_trans bool

If True, return the scale and translation applied to V

False

Returns:

Name Type Description
V numpy float array

Rescaled/translated mesh vertices

s float

Scale applied to V. only returned if return_scale_trans is True

t numpy float array

translation applied to V. only returned if return_scale_trans is True

Source code in src\fast_cody\normalize_height_and_center.py
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def normalize_height_and_center(V, h, c, return_scale_trans=False):
    """
    Normalize the height of the mesh to h and center it at c.

    Parameters
    ----------
    V : numpy float array
        Mesh vertices
    h : float
        Desired height
    c : numpy float array
        Desired center
    return_scale_trans : bool
        If True, return the scale and translation applied to V

    Returns
    -------
    V : numpy float array
        Rescaled/translated mesh vertices
    s : float
        Scale applied to V. only returned if return_scale_trans is True
    t : numpy float array
        translation applied to V. only returned if return_scale_trans is True
    """

    height = V[:, 1].max() - V[:, 1].min()

    s = h / height

    V = V * s

    d =  V.mean(axis=0) - c

    V -= d

    if return_scale_trans:
        return V, s, d
    return V