A powerful Python library for 3D visualization of geometry
Project description
Quick3D
A simple and intuitive 3D visualization library for Python that makes it easy to create, manipulate, and visualize 3D shapes without the complexity of learning low-level plotting APIs.
Features
- Easy-to-use API: Create 3D scenes with just a few lines of code
- Multiple 3D objects: Cube, Cuboid (with flexible origin positions), Cylinder, and Sphere
- Customizable axes: With grid lines and adjustable parameters
- Lighting effects: Support for light direction and ambient light
- Style customization: Customize colors, transparency, line widths, and more
- Responsive design: Automatic axis adjustment based on scene content
Installation
Quick3D requires the following dependencies:
- numpy
- matplotlib
- mpl_toolkits.mplot3d
You can install the dependencies using pip:
pip install numpy matplotlib
Quick Start
from quick3d import Scene3D, Cube3D
# Create a scene
scene = Scene3D()
# Add a cube
cube = Cube3D(center=(0, 0, 0), size=1.0)
scene.add_object(cube, style={
'facecolor': 'lightblue',
'edgecolor': 'navy',
'alpha': 0.7
})
# Show the scene
scene.show(elev=30, azim=45, axes='custom')
Documentation
Core Classes
Scene3D
The main scene management class that handles all 3D objects, lighting, and rendering.
Methods:
__init__(): Create a new sceneset_light_direction(direction: Tuple[float, float, float]): Set the direction of the light sourceset_ambient_light(intensity: float): Set the ambient light intensity (0-1)add_object(obj: Quick3D, style: Optional[Dict[str, Any]] = None): Add a 3D object to the sceneshow(elev: float = 20, azim: float = -80, **kwargs): Display the scenecreate_custom_axes(style=None, **kwargs): Create custom axes for the sceneset_custom_axes_style(style): Set the style of the custom axes
Quick3D
The base class for all 3D objects.
Methods:
set_style(style: Dict[str, Any]): Set the style of the objectget_style() -> Dict[str, Any]: Get the current style of the objectreset_default_style(): Reset the style to default valuesget_domain() -> np.ndarray: Get the bounding box of the objectget_centroid() -> np.ndarray: Get the geometric center of the object
3D Objects
Cube3D
A cube with equal dimensions in all directions.
Parameters:
center: Tuple[float, float, float] = (0, 0, 0): The center of the cubesize: float = 1.0: The size (edge length) of the cube
Cuboid3D
A rectangular prism with different dimensions in x, y, and z directions.
Parameters:
origin: Tuple[float, float, float] = (0, 0, 0): The origin pointlength: float = 2.0: The length in the x directionwidth: float = 1.0: The width in the y directionheight: float = 1.5: The height in the z directionorigin_location: str = 'center': The location of the origin relative to the cuboid
Origin Locations:
'center': Origin is at the geometric center (default)'x_min_y_min_z_min': Origin is at the minimum x, minimum y, minimum z vertex'x_max_y_min_z_min': Origin is at the maximum x, minimum y, minimum z vertex'x_min_y_max_z_min': Origin is at the minimum x, maximum y, minimum z vertex'x_max_y_max_z_min': Origin is at the maximum x, maximum y, minimum z vertex'x_min_y_min_z_max': Origin is at the minimum x, minimum y, maximum z vertex'x_max_y_min_z_max': Origin is at the maximum x, minimum y, maximum z vertex'x_min_y_max_z_max': Origin is at the minimum x, maximum y, maximum z vertex'x_max_y_max_z_max': Origin is at the maximum x, maximum y, maximum z vertex
Cylinder3D
A cylinder with a circular base.
Parameters:
center: Tuple[float, float, float] = (0, 0, 0): The center of the cylinderradius: float = 1.0: The radius of the baseheight: float = 2.0: The height of the cylinderslices: int = 32: The number of slices (segments) for the circular base
Sphere3D
A sphere.
Parameters:
center: Tuple[float, float, float] = (0, 0, 0): The center of the sphereradius: float = 1.0: The radius of the sphererings: int = 20: The number of rings (latitudinal segments)sectors: int = 32: The number of sectors (longitudinal segments)
Custom Axes
The CustomAxes class provides customizable axes with grid lines and coordinate planes.
Parameters:
length: float = 1.0: The length of the z-axisorigin: Tuple[float, float, float] = (0, 0, 0): The origin pointgrid_size: float = 1.0: The size of each grid cellgrid_limits: int = 8: The maximum number of grid linesgrid_color: str = 'gray': The color of the grid linesgrid_linewidth: float = 0.6: The width of the grid linesgrid_alpha: float = 0.8: The transparency of the grid linestop_margin_ratio: float = 0.1: The ratio of top margin for the gridshow_xy_plane: bool = True: Whether to show the XY plane (horizontal plane)show_xz_plane: bool = False: Whether to show the XZ planeshow_yz_plane: bool = False: Whether to show the YZ planexy_plane_color: str = '#e0e0e0': Color of the XY plane (light gray)xz_plane_color: str = '#e0f0e0': Color of the XZ plane (light green)yz_plane_color: str = '#e0e0f0': Color of the YZ plane (light blue)plane_alpha: float = 0.7: Transparency of the coordinate planes
Coordinate Planes
Quick3D supports displaying three coordinate planes (XY, XZ, YZ) that can help visualize the 3D space. The XY plane is the horizontal plane by default.
Example:
from quick3d import Scene3D
scene = Scene3D()
# Enable all coordinate planes with custom styles
axes_style = {
'show_xy_plane': True,
'show_xz_plane': True,
'show_yz_plane': True,
'xy_plane_color': '#e0e0e0', # Light gray
'xz_plane_color': '#e0f0e0', # Light green
'yz_plane_color': '#e0e0f0', # Light blue
'plane_alpha': 0.7
}
scene.set_custom_axes_style(axes_style)
Examples
Quick3D includes several example scripts in the examples directory:
basic_example.py: Basic usage of Quick3D with a cubeall_objects_example.py: Demonstrates all 3D objectscuboid_origin_example.py: Shows different origin positions for Cuboid3Dcoordinate_planes_example.py: Demonstrates the coordinate planes feature
To run an example:
python -m quick3d.examples.basic_example
License
Quick3D is released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quick3d-0.2.0.tar.gz.
File metadata
- Download URL: quick3d-0.2.0.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
043107a299de42b917c6401dc522eea41c5ec5a9ab5cbe5808d9eb6dc0bebf49
|
|
| MD5 |
cb0b99a5b3831ae84e8f65c16fd98667
|
|
| BLAKE2b-256 |
40c5ec2049f34134eceb739d69823331817a05a6ffbe5106f92dd9fb0712a2e9
|
File details
Details for the file quick3d-0.2.0-py3-none-any.whl.
File metadata
- Download URL: quick3d-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1504736c1d5293abf0ca5eea0af6d5970359b233230e44a3a772d660369a6f25
|
|
| MD5 |
4894d7989d1d5ae6054d9c40afbec8cf
|
|
| BLAKE2b-256 |
8e262e95b016b705bbae769639cdac8ac81d5d8c043a387cc31157bc1ee83099
|