POV-Ray : Newsgroups : povray.general : Scaling macros? Server Time
4 Aug 2024 08:26:02 EDT (-0400)
  Scaling macros? (Message 11 to 15 of 15)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Tom Galvin
Subject: Re: Scaling macros?
Date: 31 Jul 2003 02:46:40
Message: <Xns93C91C153F90Etomatimporg@204.213.191.226>
John VanSickle <evi### [at] hotmailcom> wrote in 
news:3F26A95E.4D3834F1@hotmail.com:


> 
> PS:  Pardon me if this has been done.

Sonya Roberts did it in 1997 ;)  From micrometer to lightyear

http://www.imp.org/media/archives/units.zip



-- 
Tom
_________________________________
The Internet Movie Project
http://www.imp.org/


Post a reply to this message

From: Dick Balaska
Subject: Re: Scaling macros?
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

From: Mark Wagner
Subject: Re: Scaling macros?
Date: 1 Aug 2003 05:30:36
Message: <pan.2003.08.01.09.30.31.726050.352@gte.net>
On Tue, 29 Jul 2003 14:01:39 -0700, gonzo quoth:

> How do all you POV masters handle your units?

I've got a file that I include called "units.inc" that defines assorted
units of measurement in terms of each other.  It defaults to 1 cm = 1 POV
unit, but if I change the definition of a centimeter before including the
file, it adjusts all units accordingly.  This way, I can mix inches,
centimeters, feet, and light years without any trouble.

-- 
Mark


Post a reply to this message

From: gonzo
Subject: Re: Scaling macros?
Date: 1 Aug 2003 14:20:01
Message: <web.3f2aae259c12b543a0c272b50@news.povray.org>
Christopher James Huff wrote:
>In article <web.3f26e01d9c12b543a0c272b50[at]news.povray.org>,
>
>You could also base them all off of one value:
>
>#declare m = 1;
>#declare cm = m/100;
>#declare mm = m/1000;
>#declare km = m*1000;
>#declare in = m/0.0254;
>#declare ft = in*12;
>#declare yd = ft*3;
>#declare mi = km/1.607347;
>
>This way, you only have one constant to change...the number of units in
>a meter, in this case. If everyone uses the same unit names, all you
>have to do is change that value. (or just remove it and place it
>elsewhere, such as in a "units.inc" file)
>


Yes, that is what I meant.  I define Ft = 1 unit, then everything else is
based on Ft.  So far I haven't used much past yards though... guess I need
to expand my horizons to get into light years ;-)

RG


Post a reply to this message

From: gonzo
Subject: Re: Scaling macros?
Date: 1 Aug 2003 14:40:00
Message: <web.3f2ab1339c12b543a0c272b50@news.povray.org>
Mark Wagner wrote:
>On Tue, 29 Jul 2003 14:01:39 -0700, gonzo quoth:
>
>> How do all you POV masters handle your units?
>
>I've got a file that I include called "units.inc" that defines assorted
>units of measurement in terms of each other.  It defaults to 1 cm = 1 POV
>unit, but if I change the definition of a centimeter before including the
>file, it adjusts all units accordingly.  This way, I can mix inches,
>centimeters, feet, and light years without any trouble.
>
>Mark
>

Thanks all for the comments & insights!  I hope John got the info he needed
from this thread, but even if he didn't I certainly found it informative!

This was something I had recently been running up against since my
"architecture" IRTC entry. That one pretty much demanded a standardized
method of scaling, so I started using feet since most building specs (at
least here in the US) are in feet.

Once I started using that though, I found I had problems with earlier models
where I had hard coded numbers or used arbitrary unit sizes. Some were so
bad it was easier to build a new model than to convert the old one!

So now I have my unit standard, and it sounds like enough people are using a
system similar enough that conversion shouldn't be a major issue. (And I
should have some good objects to share in my surreal IRTC entry, as long as
I get it done in time...)

Thanks again!

RG


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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