graphics.vector3_for_2d_rendering

render 3d points for 2d surfaces.

Attributes

__author__

__version__

Functions

convert_to_2d(→ tuple[float, float])

Converts 3d point to a 2d drawable point

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

rotate a point around a certain axis with a certain angle

Module Contents

graphics.vector3_for_2d_rendering.convert_to_2d(x: float, y: float, z: float, scale: float, distance: float) tuple[float, float]

Converts 3d point to a 2d drawable point

>>> convert_to_2d(1.0, 2.0, 3.0, 10.0, 10.0)
(7.6923076923076925, 15.384615384615385)
>>> convert_to_2d(1, 2, 3, 10, 10)
(7.6923076923076925, 15.384615384615385)
>>> convert_to_2d("1", 2, 3, 10, 10)  # '1' is str
Traceback (most recent call last):
    ...
TypeError: Input values must either be float or int: ['1', 2, 3, 10, 10]
graphics.vector3_for_2d_rendering.rotate(x: float, y: float, z: float, axis: str, angle: float) tuple[float, float, float]

rotate a point around a certain axis with a certain angle angle can be any integer between 1, 360 and axis can be any one of ‘x’, ‘y’, ‘z’

>>> rotate(1.0, 2.0, 3.0, 'y', 90.0)
(3.130524675073759, 2.0, 0.4470070007889556)
>>> rotate(1, 2, 3, "z", 180)
(0.999736015495891, -2.0001319704760485, 3)
>>> rotate('1', 2, 3, "z", 90.0)  # '1' is str
Traceback (most recent call last):
    ...
TypeError: Input values except axis must either be float or int: ['1', 2, 3, 90.0]
>>> rotate(1, 2, 3, "n", 90)  # 'n' is not a valid axis
Traceback (most recent call last):
    ...
ValueError: not a valid axis, choose one of 'x', 'y', 'z'
>>> rotate(1, 2, 3, "x", -90)
(1, -2.5049096187183877, -2.5933429780983657)
>>> rotate(1, 2, 3, "x", 450)  # 450 wrap around to 90
(1, 3.5776792428178217, -0.44744970165427644)
graphics.vector3_for_2d_rendering.__author__ = 'xcodz-dot, cclaus, dhruvmanila'
graphics.vector3_for_2d_rendering.__version__ = '2020.9.26'