Skip to content

Commit

Permalink
docs: added images for generic component docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kieran-mackle committed Dec 17, 2023
1 parent 9a5814a commit 57e3191
Show file tree
Hide file tree
Showing 12 changed files with 148 additions and 32 deletions.
30 changes: 0 additions & 30 deletions docs/source/documentation/components/general.md

This file was deleted.

56 changes: 56 additions & 0 deletions docs/source/documentation/components/generic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generic Component Types

The following page documents the generic component types of <tt>HyperVehicle</tt>.
These are not vehicle-specific. Note that an example script is provided for each
component type in the <tt>HyperVehicle</tt>
[examples](https://github.com/kieran-mackle/hypervehicle/blob/development/examples/)
directory.
<!-- [examples](https://github.com/kieran-mackle/hypervehicle/blob/master/examples/) -->


## Revolved Component
<!-- Example: [`revolved.py`](https://github.com/kieran-mackle/hypervehicle/blob/master/examples/components/revolved.py) -->
Example: [`revolved.py`](https://github.com/kieran-mackle/hypervehicle/blob/development/examples/components/revolved.py)

Revolved geometries can be constructed using the {py:class}`.RevolvedComponent`.
This component is defined primarily by the line to be revolved.

![revolved component](../../images/components/revolve.png)


## Swept Component
<!-- Example: [`swept.py`](https://github.com/kieran-mackle/hypervehicle/blob/master/examples/components/swept.py) -->
Example: [`swept.py`](https://github.com/kieran-mackle/hypervehicle/blob/development/examples/components/swept.py)

Swept geometries can be constructed using a {py:class}`.SweptComponent` type. This
component requires a series of cross-sectional patches to be defined.

![swept component](../../images/components/swept.png)


## Cube Component
<!-- Example: [`cube.py`](https://github.com/kieran-mackle/hypervehicle/blob/master/examples/components/cube.py) -->
Example: [`cube.py`](https://github.com/kieran-mackle/hypervehicle/blob/development/examples/components/cube.py)

A cube can be constructed via the {py:class}`.Cube` class. It only requires the cube side
length to be provided.

![cube component](../../images/components/cube.png)


## Sphere Component
<!-- Example: [`sphere.py`](https://github.com/kieran-mackle/hypervehicle/blob/master/examples/components/sphere.py) -->
Example: [`sphere.py`](https://github.com/kieran-mackle/hypervehicle/blob/development/examples/components/sphere.py)

A sphere can be constructed using the {py:class}`.Sphere` class. Like the cube, it
only requires a radius to be defined.

![sphere component](../../images/components/sphere.png)


## Composite Component
In some advanced instances, you may wish to combine the patches of various components
into a single component. Or, you may have defined your own patch types. For this purpose,
the {py:class}`.CompositeComponent` class is available. This class allows a user to stack
individual {py:class}`.Component` objects to form a composite, which can then be added to
the {py:class}`.Vehicle`, for example.
5 changes: 3 additions & 2 deletions docs/source/documentation/components/index.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# HyperVehicle Components

As described in the [<tt>HyperVehicle</tt> overview](overview), a component-based approach is
used to construct geometries. We classify two types of components: general components and vehicle components. The former refers to components defined by operations you may already be familiar
used to construct geometries. We classify two types of components: generic components and vehicle
components. The former refers to components defined by operations you may already be familiar
with from a CAD context, while the latter refers to components made specifically to help define
hypersonic vehicle geometries.


```{toctree}
:maxdepth: 1
General Components <general>
Generic Components <generic>
Vehicle Components <vehicle>
```
Binary file added docs/source/images/components/cube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/components/revolve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/components/sphere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/images/components/swept.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions examples/components/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Example Component Generation Scripts

This directory contains the scripts used to generate the components shown in the documentation.


6 changes: 6 additions & 0 deletions examples/components/cube.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from hypervehicle.components import Cube


cube = Cube(a=1, stl_resolution=5)
cube.generate_patches()
cube.to_stl(outfile="cube.stl")
22 changes: 22 additions & 0 deletions examples/components/revolved.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from hypervehicle.components import RevolvedComponent
from hypervehicle.geometry import Vector3, Bezier, RobertsFunction


# Define the curve to be revolved
curve = Bezier(
[
Vector3(x=0.0, y=0.0),
Vector3(x=0.5, y=0.1),
Vector3(x=0.9, y=0.5),
Vector3(x=1.0, y=0.0),
]
)

# Define clustering function
clustering = RobertsFunction(False, True, 1.01)

# Create the component
component = RevolvedComponent(revolve_line=curve, stl_resolution=50)
component.add_clustering_options(i_clustering_func=clustering)
component.generate_patches()
component.to_stl("revolve.stl")
6 changes: 6 additions & 0 deletions examples/components/sphere.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from hypervehicle.components import Sphere


sphere = Sphere(r=1, stl_resolution=20)
sphere.generate_patches()
sphere.to_stl(outfile="sphere.stl")
50 changes: 50 additions & 0 deletions examples/components/swept.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
from hypervehicle.components import SweptComponent
from hypervehicle.geometry import Vector3, Line, CoonsPatch


# We will generate the wedge shown below by sweeping the
# cross section shown below through the width of the geometry
# ^ +y
# |
# W _ - _ N ___
# _ - | - _ |
# +x <--- < -------------- > | thickness
# - _ | _ - |
# S - _ - E ___
# |-----------------|
# length
thickness = 0.25
length = 1
width = 1

# Define the patches to sweep through
NW = Vector3(x=0, y=0.5 * thickness)
NE = Vector3(
x=-0.5 * width,
y=0,
)
SE = Vector3(x=0, y=-0.5 * thickness)
SW = Vector3(x=0.5 * width, y=0)

# Define two patches forming wedge
sections = []
for i in [-1, 1]:
z_loc = 0.5 * i * length
axial_shift = Vector3(x=0, y=0, z=z_loc)

N = Line(p0=NW + axial_shift, p1=NE + axial_shift)
S = Line(p0=SW + axial_shift, p1=SE + axial_shift)
E = Line(p0=SE + axial_shift, p1=NE + axial_shift)
W = Line(p0=SW + axial_shift, p1=NW + axial_shift)

patch = CoonsPatch(north=N, south=S, east=E, west=W)
sections.append(patch)

# Create the component
component = SweptComponent(
cross_sections=sections,
sweep_axis="z",
stl_resolution=10,
)
component.generate_patches()
component.to_stl("swept.stl")

0 comments on commit 57e3191

Please sign in to comment.