pohlke.utils.geometry_math#

Contains all usefull mathematical functions for the add-on

Attributes#

Functions#

calculate_oblique_attributes(→ float)

Calculates the second attribute of an oblique projection (beta or alpha) from the first one (alpha or beta). If the input parameter is alpha, the function returns beta, and vice versa.

calculate_oblique_z_axis(→ float)

Calculate the Z-axis reduction factor of an oblique projection using it alpha parameter

calculate_altitude_with_z_value(→ float)

Calculate the projection's altitude using it Z-axis reduction factor

compute_scales(→ tuple[float, float, float])

Calculate scale factors for given axonometry inclination angles.

tilt(→ tuple[float, float])

Coordinate plane tilt.

get_tilted_angles(→ list[tuple[float]])

Order by coordinate plane is XY, ZY, ZX.

calculate_axonometric_rotation(→ float)

Calculate the rotation of an axonometric projection with its alpha and beta parameters

calculate_axonometric_altitude(beta_rad, alpha_rad)

Calculate the altitude of an axonometric projection with its alpha and beta parameters

normalize_factors(x, y, z)

Normalize axonometric reduction factors so that the largest factor is 1.0

Module Contents#

pohlke.utils.geometry_math.logger[source]#
pohlke.utils.geometry_math.calculate_oblique_attributes(attribute: float) float[source]#

Calculates the second attribute of an oblique projection (beta or alpha) from the first one (alpha or beta). If the input parameter is alpha, the function returns beta, and vice versa.

Parameters#

attributefloat

One of the projection attributes (alpha or beta)

Returns#

float

The second attribute depending on the param (alpha if attribue param is beta, and vice versa)

Examples#

>>> from math import radians, degrees
>>> from utils.geometry_math import calculate_oblique_attributes
>>> oblique_beta = radians(45)
>>> oblique_alpha = calculate_oblique_attributes(oblique_beta)
>>> print(degrees(oblique_alpha))
45
>>> oblique_alpha = radians(30)
>>> oblique_beta = calculate_oblique_attributes(oblique_alpha)
>>> print(degrees(oblique_beta))
60
pohlke.utils.geometry_math.calculate_oblique_z_axis(alpha: float) float[source]#

Calculate the Z-axis reduction factor of an oblique projection using it alpha parameter

Parameters#

alphafloat

The alpha parameter of the projection

Returns#

float

The Z-axis reduction factor (between 0 and 1)

Examples#

>>> from math import radians
>>> from utils.geometry_math import calculate_oblique_z_axis
>>> oblique_alpha = radians(45)
>>> z = calculate_oblique_z_axis(oblique_alpha)
>>> print(z)
1.0
pohlke.utils.geometry_math.calculate_altitude_with_z_value(z_value: float) float[source]#

Calculate the projection’s altitude using it Z-axis reduction factor

Parameters#

z_valuefloat

Z-axis reduction factor of the projection (between 0 ans 1)

Returns#

float

Altitude of the projection (in radians)

Examples#

>>> from math import degrees
>>> from utils.geometry_math import calculate_altitude_with_z_value
>>> z = 1.0
>>> oblique_altitude = calculate_altitude_with_z_value(z)
>>> print(degrees(oblique_altitude))
45
pohlke.utils.geometry_math.compute_scales(beta_rad: float, alpha_rad: float) tuple[float, float, float][source]#

Calculate scale factors for given axonometry inclination angles.

Source#

Lien de référence : <https://axonometry.readthedocs.io/en/beta/>

Parameters#

beta_radfloat

The beta angle of the plan (in radians)

alpha_radfloat

The beta angle of the plan (in radians)

Returns#

tuple[float, float, float]

Axes scales

Examples#

>>> from math import degrees, radians
>>> from utils.geometry_math import compute_scales
>>> # Test with isometric projection
>>> alpha_rad = radians(30)
>>> beta_rad = radians(30)
>>> y, z, x = compute_scales(beta_rad, alpha_rad)
>>> print(x, y, z)
0.82, 0.82, 0.82
pohlke.utils.geometry_math.tilt(angles: tuple[float, float]) tuple[float, float][source]#

Coordinate plane tilt.

Source#

Lien de référence : <https://axonometry.readthedocs.io/en/beta/>

pohlke.utils.geometry_math.get_tilted_angles(beta_rad, alpha_rad) list[tuple[float]][source]#

Order by coordinate plane is XY, ZY, ZX.

Source#

Lien de référence : <https://axonometry.readthedocs.io/en/beta/>

pohlke.utils.geometry_math.calculate_axonometric_rotation(beta_rad: float, alpha_rad: float) float[source]#

Calculate the rotation of an axonometric projection with its alpha and beta parameters

Parameters#

beta_radfloat

The beta angle of the plan (in radians)

alpha_radfloat

The alpha angle of the plan (in radians)

Returns#

float

The rotation of the projection (in radians)

Examples#

>>> from math import radians, degrees
>>> from utils.geometry_math import calculate_axonometric_rotation
>>> alpha_rad = radians(30)
>>> beta_rad = radians(30)
>>> axonometric_rotation = calculate_axonometric_rotation(beta_rad, alpha_rad)
>>> print(degrees(axonometric_rotation))
45
pohlke.utils.geometry_math.calculate_axonometric_altitude(beta_rad, alpha_rad)[source]#

Calculate the altitude of an axonometric projection with its alpha and beta parameters

Parameters#

beta_radfloat

The beta angle of the plan (in radians)

alpha_radfloat

The alpha angle of the plan (in radians)

Returns#

float

The altitude of the projection (in radians)

Examples#

>>> from math import radians, degrees
>>> from utils.geometry_math import calculate_axonometric_altitude
>>> alpha_rad = radians(30)
>>> beta_rad = radians(30)
>>> axonometric_rotation = calculate_axonometric_altitude(beta_rad, alpha_rad)
>>> print(degrees(axonometric_rotation))
35.26
pohlke.utils.geometry_math.normalize_factors(x, y, z)[source]#

Normalize axonometric reduction factors so that the largest factor is 1.0 and others are scaled proportionally.

Parameters#

xfloat

The reduction factor for the X axis.

yfloat

The reduction factor for the Y axis.

zfloat

The reduction factor for the Z axis.

Returns#

tuple[float, float, float]

A tuple containing (norm_x, norm_y, norm_z) where the maximum value is 1.0. Returns (0.0, 0.0, 0.0) if all input parameters are zero.

Examples#

>>> from utils.geometry_math import normalize_reduction_factors
>>> x, y, z = 10.0, 5.0, 2.0
>>> nx, ny, nz = normalize_reduction_factors(x, y, z)
>>> print(nx, ny, nz)
1.0, 0.5, 0.2
>>> # Case with equal factors
>>> normalize_reduction_factors(0.5, 0.5, 0.5)
(1.0, 1.0, 1.0)