[OpenSCAD] Internal treatment of common expressions

Torsten Paul Torsten.Paul at gmx.de
Thu Jun 2 09:13:22 EDT 2016

Von: "L Boyd" <lboyd at frontiernet.net>
> polyhedron(
> points = [
> [cos(as)*Rroot, sin(as)*Rroot, z], //0
> [cos(as)*Rtipp, sin(as)*Rtipp, z+z1], //1
> [cos(as)*Rroot, sin(as)*Rroot, z+z2], //2
> [cos(ae)*Rroot, sin(ae)*Rroot, z+zd], //3
> [cos(ae)*Rtipp, sin(ae)*Rtipp, z+zd+z1], //4
> [cos(ae)*Rroot, sin(ae)*Rroot, z+zd+z2]], //5
> Does it calculate each of these 3 times?

> If so, is there a performance advantage to assigning
> them to variables, thus calculating them only once?
Hard to say, probably not for sin() and cos(). In case
it would call a complicated user defined function, the
pre-calculation might help a bit.

In general any simple evaluation tends to be orders
of magnitude faster than the actual mesh calculation,
or even the preview, so there's not much to gain for
the overall time needed.


More information about the Discuss mailing list