1
1
from math import cos , sin , radians , acos
2
2
import cadquery as cq
3
3
4
+
4
5
def involute (r : float , sign : int = 1 ):
5
6
"""
6
7
Defines an involute curve to create the flanks of the involute gears
@@ -12,12 +13,15 @@ def involute(r: float, sign: int = 1):
12
13
Returns:
13
14
x,y -> tuple() : 2-tuple of x and y coordinates in space
14
15
"""
16
+
15
17
def curve (t ):
16
- x = r * (cos (t ) + t * sin (t ))
17
- y = r * (sin (t ) - t * cos (t ))
18
- return x ,sign * y
18
+ x = r * (cos (t ) + t * sin (t ))
19
+ y = r * (sin (t ) - t * cos (t ))
20
+ return x , sign * y
21
+
19
22
return curve
20
23
24
+
21
25
def spherical_involute (delta , delta_b , R ):
22
26
"""
23
27
Equation of the spherical involute that lies on a sphere
@@ -30,19 +34,22 @@ def spherical_involute(delta, delta_b, R):
30
34
Returns:
31
35
x,y,z -> tuple() : 3-tuple of x and y and z coordinates in space
32
36
"""
33
- theta = acos (cos (delta )/ cos (delta_b ))/ sin (delta_b )
34
- x = R * cos (theta * sin (delta_b ))* sin (delta_b )* cos (theta ) - R * sin (theta * sin (delta_b ))* - sin (theta )
35
- y = R * cos (theta * sin (delta_b ))* sin (delta_b )* sin (theta ) - R * sin (theta * sin (delta_b ))* cos (theta )
36
- z = R * cos (theta * sin (delta_b ))* cos (delta_b )
37
- return x ,y ,z
38
-
37
+ theta = acos (cos (delta ) / cos (delta_b )) / sin (delta_b )
38
+ x = R * cos (theta * sin (delta_b )) * sin (delta_b ) * cos (theta ) - R * sin (
39
+ theta * sin (delta_b )
40
+ ) * - sin (theta )
41
+ y = R * cos (theta * sin (delta_b )) * sin (delta_b ) * sin (theta ) - R * sin (
42
+ theta * sin (delta_b )
43
+ ) * cos (theta )
44
+ z = R * cos (theta * sin (delta_b )) * cos (delta_b )
45
+ return x , y , z
39
46
40
47
41
48
def rotate_vector_2D (vector : cq .Vector , angle : float ):
42
49
"""
43
50
Rotates a 2D cq.Vector `vector`by an angle of `angle` in degrees
44
51
"""
45
52
angle = radians (angle )
46
- x = cos (angle )* vector .x - sin (angle )* vector .y
47
- y = sin (angle )* vector .x + cos (angle )* vector .y
48
- return cq .Vector ((x ,y ))
53
+ x = cos (angle ) * vector .x - sin (angle ) * vector .y
54
+ y = sin (angle ) * vector .x + cos (angle ) * vector .y
55
+ return cq .Vector ((x , y ))
0 commit comments