Skip to content

Commit a97a5b8

Browse files
committed
removed trigonometric functions from solid2 namespace (#44)
1 parent 7b757a4 commit a97a5b8

File tree

4 files changed

+5
-15
lines changed

4 files changed

+5
-15
lines changed

solid2/core/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
from .scad_import import import_scad, use, include
99

10-
from .object_base import scad_inline, scad_inline_parameter_func, sin, cos,\
11-
tan, asin, acos, atan, sqrt, not_
10+
from .object_base import scad_inline, scad_inline_parameter_func
1211

1312
from .extension_manager import register_access_syntax, register_pre_render,\
1413
register_post_render, register_root_wrapper

solid2/core/builtins/openscad_functions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ def concat(*args): return _base_fn('concat', *args)
3434
def cross(*args): return _base_fn('cross', *args)
3535
def lookup(*args): return _base_fn('lookup', *args)
3636
def rands(*args): return _base_fn('rands', *args)
37+
def not_(*args): return _base_fn('!', *args)
3738

solid2/core/object_base/object_base_impl.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,6 @@ def _render(self):
169169
from textwrap import dedent
170170
return dedent(self.value)
171171

172-
import math
173-
sin = lambda x: OpenSCADConstant(f'sin({x})') if isinstance(x, OpenSCADConstant) else math.sin(x)
174-
cos = lambda x: OpenSCADConstant(f'cos({x})') if isinstance(x, OpenSCADConstant) else math.cos(x)
175-
tan = lambda x: OpenSCADConstant(f'tan({x})') if isinstance(x, OpenSCADConstant) else math.tan(x)
176-
asin = lambda x: OpenSCADConstant(f'asin({x})') if isinstance(x, OpenSCADConstant) else math.asin(x)
177-
acos = lambda x: OpenSCADConstant(f'acos({x})') if isinstance(x, OpenSCADConstant) else math.acos(x)
178-
atan = lambda x: OpenSCADConstant(f'atan({x})') if isinstance(x, OpenSCADConstant) else math.atan(x)
179-
sqrt = lambda x: OpenSCADConstant(f'sqrt({x})') if isinstance(x, OpenSCADConstant) else math.sqrt(x)
180-
not_ = lambda x: OpenSCADConstant(f'!{x}')
181-
182172
def scad_inline(code):
183173
return OpenSCADConstant(code)
184174

solid2/examples/17-greedy-scad-interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from solid2 import *
44

55
set_global_fn(32)
6-
set_global_viewport_distance(abs(sin(get_animation_time() * 360)) * 10 + 5)
6+
set_global_viewport_distance(abs(openscad_functions.sin(get_animation_time() * 360)) * 10 + 5)
77
set_global_viewport_translation([0, -1, 0])
88
set_global_viewport_rotation([63, 0, get_animation_time() * 360])
99
set_global_viewport_fov(25)
@@ -24,7 +24,7 @@ def funny_cube():
2424
tab = "Animation")
2525

2626
return color(customized_color) (
27-
cube(abs(sin(get_animation_time() * 360 * customized_animation_factor)), center=True)
27+
cube(abs(openscad_functions.sin(get_animation_time() * 360 * customized_animation_factor)), center=True)
2828
)
2929

3030
def funny_sphere():
@@ -33,7 +33,7 @@ def funny_sphere():
3333

3434
return translate([0, -2, 0]) (
3535
color(customized_color) (
36-
sphere(r = abs(sin(get_animation_time() * 360 * customized_animation_factor - 90)))
36+
sphere(r = abs(openscad_functions.sin(get_animation_time() * 360 * customized_animation_factor - 90)))
3737
)
3838
)
3939

0 commit comments

Comments
 (0)