[OpenSCAD] Internal treatment of common expressions

L Boyd lboyd at frontiernet.net
Thu Jun 2 08:27:14 EDT 2016

A portion of my code, used many times, has the following segment:
	  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

There a 2 values of sin and 2 of cos, each of which is used 3 times.

My question is for someone familiar with the OpenSCAD internals. 

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? 

View this message in context: http://forum.openscad.org/Internal-treatment-of-common-expressions-tp17527.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

More information about the Discuss mailing list