# VisualShape3D
## About VisualShape3D
VisualShape3D is designed to facilitate the creation of 3D polygons for educational purposes. In this context, a 3D polygon is referred to as a 3D shape and is constructed through a systematic process:
1) A 2D polygon is created in the yz plane using a class called `Shape`, with specified parameters as follows:
```python
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)])
```
Once a 2D shape is created, its vertices are generated automatically.
2) The polygon is then transformed to a new position (X, Y, Z) while adopting a new orientation based on its facets. The transformation can be executed as follows:
```python
shape1 = shape1.transform(to=(X, Y, Z), angles=(alpha1, beta1))
```
Alternatively, it can be done in steps:
```python
shape1 = shape1.transform(to=(X, Y, Z))
shape1 = shape1.transform(alpha=alpha1)
shape1 = shape1.transform(beta=beta1)
```
The reference point for translation can be any 3D point; by default, the first vertex of the polygon serves as the reference point.
3) The results can then be visualized within the VisualShape3D framework, which is built upon Matplotlib:
```python
from VisualShape3D.Visual import VisualShape3D
vs3d = VisualShape3D()
vs3d.add_shape(shape1)
vs3d.show()
```
**Core Features**
The transformation process includes translation, which involves moving the reference point to a new 3D position, and rotation, which consists of adjusting the facets to a new direction about the Z-axis. The first vertex acts as the pivot point for these transformations, including rotation around the first edge. Notably, these operations are independent of one another.
## Requirements
* [Python](http://www.python.org) 3
* Matplotlib is installed.
## Documentation
To be continued.
## Installation
```bash
pip install VisualShape3D
```
## Usage
```Python
import VisualShape3D.shapes as sp
sp.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))
```
```
%matplotlib notebook
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()
```
## Update log
`1.1.6` VisualShape3D.geometry -> VisualShape3D.Shape3D; VisualShape3D.VisualModels -> VisualShape3D.Visual
`1.0.7` fix the bug of Shape_rectangleWithHole
`1.0.6` Change the about VisualShape3D
`1.0.5` Add "Modeling a house with shape" and "Building model" jupyter files
## License
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
## Contact
heliqun@ustc.edu.cn
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/VisualShape3D/",
"name": "VisualShape3D",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, VisualShape3D, windows, mac, linux",
"author": "Liqun He",
"author_email": "heliqun@ustc.edu.cn",
"download_url": "https://files.pythonhosted.org/packages/06/c1/af31393a9e3a0a69745c34991b3a93d4e1e0ce94f138dc5045382142fdd3/VisualShape3D-1.1.6.tar.gz",
"platform": null,
"description": "# VisualShape3D\r\r\n\r\r\n## About VisualShape3D\r\r\nVisualShape3D is designed to facilitate the creation of 3D polygons for educational purposes. In this context, a 3D polygon is referred to as a 3D shape and is constructed through a systematic process:\r\r\n\r\r\n1) A 2D polygon is created in the yz plane using a class called `Shape`, with specified parameters as follows:\r\r\n ```python\r\r\n from VisualShape3D.Shape3D import Shape\r\r\n shape1 = Shape('rectangle', W, H)\r\r\n shape2 = Shape('triangle', W, H, A)\r\r\n shape3 = Shape('rectangleWithHole', W, H, A, B, C, D)\r\r\n shape4 = Shape('fourSided', W, H, A, B)\r\r\n shape5 = Shape('fiveSided', W, H, A, B, C, D)\r\r\n shape6 = Shape('regularPolygon', n, R)\r\r\n shape7 = Shape('polygon', [(x1, y1), (x2, y2), ..., (xn, yn)])\r\r\n ```\r\r\n Once a 2D shape is created, its vertices are generated automatically.\r\r\n\r\r\n2) The polygon is then transformed to a new position (X, Y, Z) while adopting a new orientation based on its facets. The transformation can be executed as follows:\r\r\n ```python\r\r\n shape1 = shape1.transform(to=(X, Y, Z), angles=(alpha1, beta1))\r\r\n ```\r\r\n Alternatively, it can be done in steps:\r\r\n ```python\r\r\n shape1 = shape1.transform(to=(X, Y, Z))\r\r\n shape1 = shape1.transform(alpha=alpha1)\r\r\n shape1 = shape1.transform(beta=beta1)\r\r\n ```\r\r\n The reference point for translation can be any 3D point; by default, the first vertex of the polygon serves as the reference point.\r\r\n\r\r\n3) The results can then be visualized within the VisualShape3D framework, which is built upon Matplotlib:\r\r\n ```python\r\r\n from VisualShape3D.Visual import VisualShape3D\r\r\n vs3d = VisualShape3D()\r\r\n vs3d.add_shape(shape1)\r\r\n vs3d.show()\r\r\n ```\r\r\n\r\r\n**Core Features**\r\r\nThe transformation process includes translation, which involves moving the reference point to a new 3D position, and rotation, which consists of adjusting the facets to a new direction about the Z-axis. The first vertex acts as the pivot point for these transformations, including rotation around the first edge. Notably, these operations are independent of one another.\r\r\n\r\r\n\r\r\n## Requirements\r\r\n\r\r\n* [Python](http://www.python.org) 3 \r\r\n* Matplotlib is installed.\r\r\n\r\r\n## Documentation\r\r\n\r\r\nTo be continued.\r\r\n\r\r\n## Installation\r\r\n```bash\r\r\npip install VisualShape3D\r\r\n```\r\r\n\r\r\n## Usage\r\r\n```Python\r\r\nimport VisualShape3D.shapes as sp\r\r\nsp.shapes()\r\r\n```\r\r\n\r\r\n```\r\r\nfrom VisualShape3D.Shape3D import Shape \r\r\nW,H = 1, 0.7\r\r\nshape1 = Shape('rectangle',W,H)\r\r\nshape2 = shape1.transform(alpha = 30)\r\r\nshape3 = shape2.transform(beta = 30)\r\r\nshape4 = shape3.transform(to=(-0.5,-0.5,0))\r\r\n```\r\r\n\r\r\n```\r\r\n%matplotlib notebook\r\r\nfrom VisualShape3D import Visual as vm \r\r\nvisual = vm.VisualShape3D({'facecolor':'yellow','alpha':0.7})\r\r\nvisual.add_shape(shape1,{'facecolor':'slategrey','alpha':0.7})\r\r\nvisual.add_shape(shape2,{'facecolor':'slategrey','alpha':0.7})\r\r\nvisual.add_shape(shape3,{'facecolor':'slategrey','alpha':0.7})\r\r\nvisual.add_shape(shape4,{'facecolor':'slategrey','alpha':0.7})\r\r\nvisual.show()\r\r\n```\r\r\n\r\r\n## Update log\r\r\n`1.1.6` VisualShape3D.geometry -> VisualShape3D.Shape3D; VisualShape3D.VisualModels -> VisualShape3D.Visual\r\r\n`1.0.7` fix the bug of Shape_rectangleWithHole\r\r\n`1.0.6` Change the about VisualShape3D\r\r\n`1.0.5` Add \"Modeling a house with shape\" and \"Building model\" jupyter files\r\r\n\r\r\n\r\r\n## License\r\r\n\r\r\n This program is free software: you can redistribute it and/or modify\r\r\n it under the terms of the GNU General Public License as published by\r\r\n the Free Software Foundation, either version 3 of the License, or\r\r\n (at your option) any later version.\r\r\n\r\r\n This program is distributed in the hope that it will be useful,\r\r\n but WITHOUT ANY WARRANTY; without even the implied warranty of\r\r\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r\r\n GNU General Public License for more details.\r\r\n\r\r\n You should have received a copy of the GNU General Public License\r\r\n along with this program. If not, see <http://www.gnu.org/licenses/>.\r\r\n\r\r\n## Contact\r\r\nheliqun@ustc.edu.cn\r\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A package for easy plotting 3D Polygons in matplotlib.",
"version": "1.1.6",
"project_urls": {
"Homepage": "https://pypi.org/project/VisualShape3D/"
},
"split_keywords": [
"python",
" visualshape3d",
" windows",
" mac",
" linux"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "06c1af31393a9e3a0a69745c34991b3a93d4e1e0ce94f138dc5045382142fdd3",
"md5": "8671e045877c415c654a21e06dcde3e0",
"sha256": "1b67533cbd5f0ad323af99a6a2ed54ef0ae7086ec26b9451fb743adfdc98e4b4"
},
"downloads": -1,
"filename": "VisualShape3D-1.1.6.tar.gz",
"has_sig": false,
"md5_digest": "8671e045877c415c654a21e06dcde3e0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 38092,
"upload_time": "2024-12-19T14:36:05",
"upload_time_iso_8601": "2024-12-19T14:36:05.200240Z",
"url": "https://files.pythonhosted.org/packages/06/c1/af31393a9e3a0a69745c34991b3a93d4e1e0ce94f138dc5045382142fdd3/VisualShape3D-1.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-19 14:36:05",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "visualshape3d"
}