POV-Ray : Newsgroups : povray.general : Scaling macros? : Re: Scaling macros? Server Time
4 Aug 2024 10:20:19 EDT (-0400)
  Re: Scaling macros?  
From: Dick Balaska
Date: 31 Jul 2003 20:10:07
Message: <p08jivktnf5qlirl72lvq9uaumf37fi1qf@4ax.com>
Also sprach Christopher James Huff <cja### [at] earthlinknet> -- Tue, 29 Jul
2003 12:41:45 -0500:


>
>What I do is just define cm, mm, m, km, etc at the beginning of the 
>scene. Then I just do something like "15.7*m" when specifying a 
>dimension. A macro version could also work, something like: "km(45)"
>
>I do use lowercase identifiers here, but I don't think a collision is 
>likely for these and it helps separate them from the rest of the code.

I do a similar thing.

#declare inches=1;
#declare inch=1;
#declare feet=12*inches;
#declare foot=feet;

which makes it nice to say
#declare blah=6*feet+4*inches;	// super American dumbkopf mode of measuring.

One of the important things (to me) in modeling is to remember to scale
*everything*.

This construct is guaranteed to cause trouble:
#declare mysize=4*inches;
difference {
	box {
		<-mysize/2,-mysize/2,-mysize/2>
		<mysize/2,mysize/2,mysize/2>
	}
	cylinder {
		z*-mysize/2-1, z*mysize/2+1			// <-- evil plus and minus 1
		1*inches
	}
}

I always used +/- 1 (or 100) when doing CSG, to avoid coincidence.
When i started rescaling my objects (#declare feet=1; #declare inch=1/12;)
these +/- 1s really bit me in the butt.  It's important to say

		z*-mysize/2-1*inch, z*mysize/2+1*inch



+++
I also have a couple of non linear predefines:

#declare pi2=pi*2;
#declare rot180=pi;
#declare rot90=pi/2;
#declare rot45=pi/4;

which are useful in sin and cos.

dik


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.