Transform¶
rotate()¶
-
p5.
rotate
()¶ Rotate the display by the given angle along the given axis.
Parameters: - theta (float) – The angle by which to rotate (in radians)
- axis (np.ndarray or list) – The axis along which to rotate (defaults to the z-axis)
Returns: The rotation matrix used to apply the transformation.
Return type: np.ndarray
rotate_x()¶
-
p5.
rotate_x
()¶ Rotate the view along the x axis.
Parameters: theta (float) – angle by which to rotate (in radians) Returns: The rotation matrix used to apply the transformation. Return type: np.ndarray
rotate_y()¶
-
p5.
rotate_y
()¶ Rotate the view along the y axis.
Parameters: theta (float) – angle by which to rotate (in radians) Returns: The rotation matrix used to apply the transformation. Return type: np.ndarray
rotate_z()¶
-
p5.
rotate_z
()¶ Rotate the view along the z axis.
Parameters: theta (float) – angle by which to rotate (in radians) Returns: The rotation matrix used to apply the transformation. Return type: np.ndarray
scale()¶
-
p5.
scale
()¶ Scale the display by the given factor.
Parameters: - sx (float) – scale factor along the x-axis.
- sy (float) – scale factor along the y-axis (defaults to None)
- sz (float) – scale factor along the z-axis (defaults to None)
Returns: The transformation matrix used to appy the transformation.
Return type: np.ndarray
shear_x()¶
-
p5.
shear_x
()¶ Shear display along the x-axis.
Parameters: theta (float) – angle to shear by (in radians) Returns: The shear matrix used to apply the tranformation. Return type: np.ndarray
shear_y()¶
-
p5.
shear_y
()¶ Shear display along the y-axis.
Parameters: theta (float) – angle to shear by (in radians) Returns: The shear matrix used to apply the transformation. Return type: np.ndarray
translate()¶
-
p5.
translate
()¶ Translate the display origin to the given location.
Parameters: - x (int) – The displacement amount in the x-direction (controls the left/right displacement)
- y (int) – The displacement amount in the y-direction (controls the up/down displacement)
- z (int) – The displacement amount in the z-direction (0 by default). This controls the displacement away-from/towards the screen.
Returns: The translation matrix applied to the transform matrix.
Return type: np.ndarray
camera()¶
-
p5.
camera
(position_x, position_y, position_z, target_x, target_y, target_z, up_x, up_y, up_z)
-
p5.
camera
(position, target_position, up_vector)
-
p5.
camera
()¶ Sets the camera position for a 3D sketch. Parameters for this function define the position for the camera, the center of the sketch (where the camera is pointing), and an up direction (the orientation of the camera).
When called with no arguments, this function creates a default camera equivalent to:
camera((0, 0, height / math.tan(math.pi / 6))), (0, 0, 0), (0, 1, 0))
Parameters: - position_x (float) – x-coordinate of the position vector
- position_y (float) – y-coordinate of the position vector
- position_z (float) – z-coordinate of the position vector
- target_x (float) – x-coordinate of the target vector
- target_y (float) – y-coordinate of the target vector
- target_z (float) – z-coordinate of the target vector
- up_x (float) – x-coordinate of the up vector
- up_y (float) – y-coordinate of the up vector
- up_z (float) – z-coordinate of the up vector
- position (tuple) – camera position coordinates
- target_position (tuple) – target position of camera in world coordinates
- up_vector (tuple) – up direction vector for the camera
perspective()¶
-
p5.
perspective
()¶ Sets a perspective projection for the camera in a 3D sketch.
Parameters: - fovy (float) – camera frustum vertical field of view, from bottom to top of view, in angleMode units
- aspect (float) – camera frustum aspect ratio
- near (float) – frustum near plane length
- far (float) – frustum far plane length
ortho()¶
-
p5.
ortho
()¶ Sets an orthographic projection for the camera in a 3D sketch and defines a box-shaped viewing frustum within which objects are seen.
Parameters: - left (float) – camera frustum left plane
- right (float) – camera frustum right plane
- bottom (float) – camera frustum bottom plane
- top (float) – camera frustum top plane
- near (float) – camera frustum near plane
- far (float) – camera frustum far plane