POV-Ray : Newsgroups : povray.general : Scaling macros? Server Time
5 Nov 2024 03:18:33 EST (-0500)
  Scaling macros? (Message 1 to 10 of 15)  
Goto Latest 10 Messages Next 5 Messages >>>
From: John VanSickle
Subject: Scaling macros?
Date: 29 Jul 2003 13:05:37
Message: <3F26A95E.4D3834F1@hotmail.com>
Let's say I design a scene using centimeters.  You design a model using
meters, or some English unit.

Who would find a set of relatively automatic scale converters
useful?

The way I envision them, the scene builder calls one macro early in
the scene:

  ExpectMeters()

while the model maker calls another macro in their code:

union {
  sphere { pHere,rSize }
  // etc

  UseCentimeters()
}

The two macros work together to make sure that the latter item is
scaled properly (in this example, by 1/100).

Except for models using IK, the macros are pretty easy to do.  Any
takers?

Regards,
John

PS:  Pardon me if this has been done.


Post a reply to this message

From: Christopher James Huff
Subject: Re: Scaling macros?
Date: 29 Jul 2003 13:41:45
Message: <cjameshuff-DE318D.12414529072003@netplex.aussie.org>
In article <3F26A95E.4D3834F1@hotmail.com>,
 John VanSickle <evi### [at] hotmailcom> wrote:

> Let's say I design a scene using centimeters.  You design a model using
> meters, or some English unit.
> 
> Who would find a set of relatively automatic scale converters
> useful?

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.


> union {
>   sphere { pHere,rSize }
>   // etc
> 
>   UseCentimeters()
> }

I think this is a bit harder to read, putting the units separate from 
the values, and it might slow things down by forcing transformations to 
be evaluated unnecessarily, especially in the case of CSG.


union {
  sphere { pHere*cm, rSize*cm }
  // etc
}

union {
  sphere { pHere, rSize scale cm}
  // etc
}

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Dave Matthews
Subject: Re: Scaling macros?
Date: 29 Jul 2003 15:40:00
Message: <web.3f26cd289c12b5437196f5900@news.povray.org>
Christopher James Huff wrote:

>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.

What a simple, convenient, smart, clean way to do things.  How come I don't
think like that?

As long as others do, and I copy your ideas, I guess I'm ok.

Thanks for the tip.

I'll be using it a lot.

Dave Matthews


Post a reply to this message

From: gonzo
Subject: Re: Scaling macros?
Date: 29 Jul 2003 17:05:01
Message: <web.3f26e01d9c12b543a0c272b50@news.povray.org>
John VanSickle wrote:
>Let's say I design a scene using centimeters.  You design a model using
>meters, or some English unit.
>
>Who would find a set of relatively automatic scale converters
>useful?
>
>The way I envision them, the scene builder calls one macro early in
>the scene:
>
>  ExpectMeters()
>
>while the model maker calls another macro in their code:
>
>union {
>  sphere { pHere,rSize }
>  // etc
>
>  UseCentimeters()
>}
>
>The two macros work together to make sure that the latter item is
>scaled properly (in this example, by 1/100).
>


Well, being UScentric, I have been using (usually) 1 pov unit = 1 Ft.  I
don't usually use other people's models so haven't had a problem, but as my
model collection grows I've been thinking about posting some of them to the
Pov-Ray object library, so I suppose others might find that useful.

I usually do basically what Chris described, defining my units at the start
of the file like #declare Ft = 1; #declare In = Ft/12; etc and using
something like 'translate x*14.25*Ft' or '#declare Rad = 5.5*In'.  Not sure
how your macro would handle that.

But this is something I have been wondering myself, how others deal with
different scalings and unit sizes.  I've tried to keep all of mine together
and right at the top of the file so if someone wanted to do their own
conversion it shouldn't be too difficult.

How do all you POV masters handle your units?

RG


Post a reply to this message

From: Christopher James Huff
Subject: Re: Scaling macros?
Date: 29 Jul 2003 17:53:22
Message: <cjameshuff-BD125F.16532229072003@netplex.aussie.org>
In article <web.3f26e01d9c12b543a0c272b50@news.povray.org>,
 "gonzo" <rgo### [at] lansetcom> wrote:

> But this is something I have been wondering myself, how others deal with
> different scalings and unit sizes.  I've tried to keep all of mine together
> and right at the top of the file so if someone wanted to do their own
> conversion it shouldn't be too difficult.

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)

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Scaling macros?
Date: 29 Jul 2003 20:03:40
Message: <pan.2003.07.30.00.07.09.69031@THISSHOULDBEREMOVEDhotmail.com>
On Tue, 29 Jul 2003 16:53:22 -0500, Christopher James Huff wrote:

...
> #declare in = m/0.0254;
...

Hmmm... Are you sure about this Christopher ?

;)


Tor Olav


Post a reply to this message

From: Christopher James Huff
Subject: Re: Scaling macros?
Date: 29 Jul 2003 20:11:54
Message: <cjameshuff-2BF323.19115429072003@netplex.aussie.org>
In article 
<pan### [at] THISSHOULDBEREMOVEDhotmailcom>,
 "Tor Olav Kristensen" <tor### [at] THISSHOULDBEREMOVEDhotmailcom> 
 wrote:

> > #declare in = m/0.0254;
> ...
> 
> Hmmm... Are you sure about this Christopher ?

Ah...I guess that should be multiplication, shouldn't it...

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Scaling macros?
Date: 29 Jul 2003 20:45:13
Message: <pan.2003.07.30.00.48.41.771613@THISSHOULDBEREMOVEDhotmail.com>
On Tue, 29 Jul 2003 19:11:54 -0500, Christopher James Huff wrote:

> In article 
> <pan### [at] THISSHOULDBEREMOVEDhotmailcom>,
>  "Tor Olav Kristensen" <tor### [at] THISSHOULDBEREMOVEDhotmailcom> 
>  wrote:
> 
>> > #declare in = m/0.0254;
>> ...
>> 
>> Hmmm... Are you sure about this Christopher ?
> 
> Ah...I guess that should be multiplication, shouldn't it...


Yes (Unless you have very long inches in the US)


Tor Olav


Post a reply to this message

From: JC (Exether)
Subject: Re: Scaling macros?
Date: 30 Jul 2003 04:59:39
Message: <3F2788FA.1050401@spam.fr>
Cool thread, it's always interesting to see how others handle common 
problems.
I use to define all my models in meters. And when it is not appropriate 
I define the object in centimeters for example and then I scale the 
whole model to meters. I do the same with models I get from outside.

JC

John VanSickle wrote:
> Let's say I design a scene using centimeters.  You design a model using
> meters, or some English unit.
> 
> Who would find a set of relatively automatic scale converters
> useful?
> 
> The way I envision them, the scene builder calls one macro early in
> the scene:
> 
>   ExpectMeters()
> 
> while the model maker calls another macro in their code:
> 
> union {
>   sphere { pHere,rSize }
>   // etc
> 
>   UseCentimeters()
> }
> 
> The two macros work together to make sure that the latter item is
> scaled properly (in this example, by 1/100).
> 
> Except for models using IK, the macros are pretty easy to do.  Any
> takers?
> 
> Regards,
> John
> 
> PS:  Pardon me if this has been done.


Post a reply to this message

From:
Subject: Re: Scaling macros?
Date: 30 Jul 2003 21:06:20
Message: <3f286b8c@news.povray.org>
> #declare m = 1;
> #declare cm = m/100;
> #declare mm = m/1000;

I strongly suggest to use MUCH larger values if possible; see my
thread "Small is NOT BEAUTIFUL" in p.g, 11 Feb. 2003. Especially
transparency, almost-coincident surfaces and shadows are highly
problematic. For indoor scenes of "normal" scale I suggest to
use 1 POV-unit = 1 mm or less.

   Sputnik


P.S. If the sphere in the second "Small is NOT BEAUTIFUL" demo scene
     is removed, then all errors are reduced by about three orders
     of magnitude -- try with scale 0.004!


Post a reply to this message

Goto Latest 10 Messages Next 5 Messages >>>

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