-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create gear_generator.py * Add bevel gear * Update gear_generator.py * add crown gear * Create rack_gear.py * add docstring, improve organisation * changed imports * add readme and setup files * moved to module dir structure Implemented the same changes as @marcus7070 did for the more_selectors plugin * update functions calls * testing import solutions * made plugin functions work * setup test functions * Update .gitignore * add working tests * add auto link of methods in __init__ * change function names * Update cutter_objects.py * add register fct to modules * add imgs for readme * finalize PR version * Update README.md * Update test_gear_generator.py * Rewrote the plugin in OOP I rewrote the plugin using OOP. For now there is only bevel gear and spur gear, I removed all the other ones cause they werent mature enough * correction of error in rotation angle change twist angle from radians to degrees * Update test_gear_generator.py modified tests to handle the update in twistangle * Update test_gear_generator.py modify precision due to difference with ubuntu 18.04 Trying hacky stuff and triggering the test * Revert "Trying hacky stuff" This reverts commit a37287b. --------- Co-authored-by: Marcus Boyd <[email protected]>
- Loading branch information
1 parent
d263aa9
commit de5a349
Showing
11 changed files
with
606 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Gear generator | ||
|
||
This plugin provide classes to create various gears. | ||
As for now you can create these gears (all the gears are involutes): | ||
* Spur gear | ||
|
||
<img src="images/straight_gear.PNG" width="600"/> | ||
|
||
* Helical gear | ||
|
||
<img src="images/helical_gear.PNG" width="600"/> | ||
|
||
* Bevel gear (straight and helical) | ||
|
||
<img src="images/bevel_gear.PNG" width="600"/> | ||
|
||
* Bevel gear system (straight and helical) | ||
|
||
<img src="images/bevel_gear_system.PNG" width="600"/> | ||
|
||
|
||
## Installation | ||
|
||
To install this plugin, the following line should be used. | ||
|
||
``` | ||
pip install -e "git+https://github.com/CadQuery/cadquery-plugins.git#egg=gear_generator&subdirectory=plugins/gear_generator" | ||
``` | ||
|
||
|
||
## Dependencies | ||
|
||
This plugin has no dependencies other than the cadquery library. | ||
|
||
## Usage | ||
|
||
To use this plugin after it has been installed, import it and create Gear objects | ||
```python | ||
import cadquery as cq | ||
import gear_generator | ||
|
||
module = 2 | ||
nb_teeth = 12 | ||
width = 8 | ||
gear = Gear(module, nb_teeth, width).build() #Instantiate a gear object and call it's build method to get the gear in a cq.Workplane | ||
``` | ||
<img src="images/readme_example.PNG" width="300"/> | ||
|
||
Below is the list of implemented gear classes : | ||
```python | ||
Gear(args) | ||
BevelGear(args) | ||
BevelGearSystem(args) | ||
|
||
#You can get info about the parameters by running | ||
help(BevelGear) | ||
|
||
Help on class Gear in module gear_generator.main: | ||
|
||
class Gear(BaseGear) | ||
| Gear(m: float, z: int, b: float, alpha: float = 20, helix_angle: float = 0, raw: bool = False) | ||
| | ||
| Base gear class | ||
| This class stores attributes that are shared by any types of gear | ||
| Other gear classes inherit from this class | ||
| | ||
| Attributes : | ||
| m : gear modulus | ||
| b : gear tooth facewidth | ||
| z : gear number of teeth | ||
| p : gear pitch | ||
-- Suite -- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .main import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from math import cos, sin, radians, acos | ||
import cadquery as cq | ||
|
||
def involute(r: float, sign: int = 1): | ||
""" | ||
Defines an involute curve to create the flanks of the involute gears | ||
Args: | ||
r : Radius of the involute (for a gear it's the pitch radius) | ||
sign : 1 or -1 , to draw the involute in positive or negative direction | ||
Returns: | ||
x,y -> tuple() : 2-tuple of x and y coordinates in space | ||
""" | ||
def curve(t): | ||
x = r*(cos(t) + t*sin(t)) | ||
y = r*(sin(t) - t*cos(t)) | ||
return x,sign*y | ||
return curve | ||
|
||
def spherical_involute(delta, delta_b, R): | ||
""" | ||
Equation of the spherical involute that lies on a sphere | ||
Args: | ||
delta : the function variable, goes from the gear root cone angle to the gear tip cone angle | ||
delta_b : angle of the base cone | ||
R : radius of the associated sphere | ||
Returns: | ||
x,y,z -> tuple() : 3-tuple of x and y and z coordinates in space | ||
""" | ||
theta = acos(cos(delta)/cos(delta_b))/sin(delta_b) | ||
x = R*cos(theta*sin(delta_b))*sin(delta_b)*cos(theta) - R*sin(theta*sin(delta_b))* - sin(theta) | ||
y = R*cos(theta*sin(delta_b))*sin(delta_b)*sin(theta) - R*sin(theta*sin(delta_b))* cos(theta) | ||
z = R*cos(theta*sin(delta_b))*cos(delta_b) | ||
return x,y,z | ||
|
||
|
||
|
||
def rotate_vector_2D(vector: cq.Vector, angle: float): | ||
""" | ||
Rotates a 2D cq.Vector `vector`by an angle of `angle` in degrees | ||
""" | ||
angle = radians(angle) | ||
x = cos(angle)*vector.x - sin(angle)*vector.y | ||
y = sin(angle)*vector.x + cos(angle)*vector.y | ||
return cq.Vector((x,y)) |
Oops, something went wrong.