Skip to content

Fixed linting and test errors for changes in CQ since PR was first opened #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/gear_generator/gear_generator/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .main import *
from .main import *
31 changes: 19 additions & 12 deletions plugins/gear_generator/gear_generator/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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
Expand All @@ -12,12 +13,15 @@ def involute(r: float, sign: int = 1):
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
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
Expand All @@ -30,19 +34,22 @@ def spherical_involute(delta, delta_b, R):
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

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))
x = cos(angle) * vector.x - sin(angle) * vector.y
y = sin(angle) * vector.x + cos(angle) * vector.y
return cq.Vector((x, y))
Loading
Loading