Skip to main content

A package of creating a visible 3D polygon with its dimensions as well as its orietation

Project description

Project Overview

VisualShape3D is such a Python library that is meant to easily create 3D polygons for modeling physics in classroom.

About VisualShape3D

Shape Creation

2D Polygon Generation :

Initially, a polygon is defined in the YZ plane with its first vertice located at the orign of XYZ system and its facet in the direction of X.

from VisualShape3D.Shape3D import Shape

shape1 = Shape('rectangle', W, H)
shape2 = Shape('triangle', W, H, A)
shape3 = Shape('rectangleWithHole', W, H, A, B, C, D)
shape4 = Shape('fourSided', W, H, A, B)
shape5 = Shape('fiveSided', W, H, A, B, C, D)
shape6 = Shape('regularPolygon', n, R)
shape7 = Shape('polygon', [(x1, y1), (x2, y2), ..., (xn, yn)])

In the YZ plane, these polygon are 2D, and easily, their vertices are generated given its dimensions.

Transformation

For a created polygon, it can move from (0,0,0) to (X, Y, Z) with regards to its origin, and its orientation of facet in the X direction can turn to others by anticlockwise rotation $alpha$ about a line in parallel to the Z axis that is passing through the first vertice, and clockwise rotation of $beta$ about its horizontal bottom edge.

The way to do them

shape1 = shape1.transform(to=(X, Y, Z))
shape1 = shape1.transform(alpha=alpha1)
shape1 = shape1.transform(beta=beta1)

Or the compact way

shape1 = shape1.transform(to=(X, Y, Z), angles=(alpha1, beta1))

Reference point

By default, the first vertex of polygon serves for the reference point of translation, but one can choose other one of the polygon by argument 'reference='.

Visualization

Built - on Matplotlib: Visualize the results within the VisualShape3D framework, which is built on Matplotlib.

from VisualShape3D.Visual import VisualShape3D

vs3d = VisualShape3D()
vs3d.add_shape(shape1)
vs3d.show()

A complete example

to list all shapes of polygons in the package that are ready for use :

import VisualShape3D.shapes as sp
sp.shapes()

To show how to use the package

To Create shapes

from VisualShape3D.Shape3D import Shape 
W, H = 1, 0.7
shape1 = Shape('rectangle', W, H)
shape2 = shape1.transform(alpha = 30)
shape3 = shape2.transform(beta = 30)
shape4 = shape3.transform(to=(-0.5,-0.5,0))

To show them all

from VisualShape3D import Visual as vm 
visual = vm.VisualShape3D({'facecolor':'yellow','alpha':0.7})
visual.add_shape(shape1,{'facecolor':'slategrey','alpha':0.7})
visual.add_shape(shape2,{'facecolor':'slategrey','alpha':0.7})
visual.add_shape(shape3,{'facecolor':'slategrey','alpha':0.7})
visual.add_shape(shape4,{'facecolor':'slategrey','alpha':0.7})
visual.show()

Core Features

Translation

Moves the reference point of the shape to a new 3D position.

Rotation

Adjusts the facets of the shape to a new direction about the Z - axis. The first vertex serves as the pivot point for these transformations, including rotation around the first edge. These operations are independent of each other.

Visualization

Show the result of modeling at all once.

Requirements

Python 3 is required, and Matplotlib must be installed.

Installation

You can easily install VisualShape3D using pip: pip install VisualShape3D

Update Log

Version 1.1.8. Improvement of projection description.
Version 1.1.7: Renamed VisualShape3D.shapes to VisualShape3D.Polygons Version 1.1.6: Renamed VisualShape3D.geometry to VisualShape3D.Shape3D and VisualShape3D.VisualModels to VisualShape3D.Visual. Version 1.0.7: Fixed the bug of Shape_rectangleWithHole. Version 1.0.6: Changed the description about VisualShape3D. Version 1.0.5: Added "Modeling a house with shape" and "Building model" jupyter files.

Documentation

Documentation is still in progress. Stay tuned for more detailed guides on using VisualShape3D.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

visualshape3d-1.1.8.tar.gz (38.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

VisualShape3D-1.1.8-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file visualshape3d-1.1.8.tar.gz.

File metadata

  • Download URL: visualshape3d-1.1.8.tar.gz
  • Upload date:
  • Size: 38.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for visualshape3d-1.1.8.tar.gz
Algorithm Hash digest
SHA256 0baeadfc2d86598d19884214c490d81f40cf53050a006fa107126ab776422765
MD5 ca491976574b947b5d3f4f6df762a61b
BLAKE2b-256 35e5f7749d76dd080e6aad7b90b32052db378c6f0ea958def896dd7f86e68b73

See more details on using hashes here.

File details

Details for the file VisualShape3D-1.1.8-py3-none-any.whl.

File metadata

  • Download URL: VisualShape3D-1.1.8-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for VisualShape3D-1.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fb68c08b469a25bae4eb89fff75fa9c3edeac34faf895f0aaecd03cd9663f9bd
MD5 b8a506cac74ebb571a3bcf313f6e2dd3
BLAKE2b-256 cb748c4c76993d1773a7156ed2bee0d6be0cc514cdeed1385fbd4b3461e45473

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page