POV-Ray : Newsgroups : povray.general : A few useful macros Server Time
5 Nov 2024 03:17:11 EST (-0500)
  A few useful macros (Message 1 to 3 of 3)  
From: Margus Ramst
Subject: A few useful macros
Date: 10 Dec 1998 06:54:27
Message: <01be2433$5a4ed380$7c01a8c0@b14.sise.ebs>
Here are some little macros that have recently saved me a lot of typing. I
also submitted them to Twyst's #MacroScope (and I recommend you send your
macros there, too)
I hope you'll find these useful

Improved interpolation function
GC - global current
GS - global start
GE - global end
TS - target start
TE - target end
EXP - interpolation exponent (linear, cubic etc.)

#macro Interpolate(GC,GS,GE,TS,TE,EXP)
        (TS+(TE-TS)*pow((GC-GS)/(GE-GS),EXP))
#end

Vector debug, saves a lot of typin when generating debug streams for 3D
vectors
Requires the vector identifier

#macro v_debug(V)
concat("<",str(V.x,0,3),",",str(V.y,0,3),",",str(V.z,0,3),">")
#end

Put point at the axis defined by P1 and P2, at a specified distance from
P2; negative distance values move the point from P2 towards P1
P1 - start point
P2 - end point
Dist - distance from P2

#macro v_lineup(P1,P2,Dist)
        (P2+vnormalize(P2-P1)*Dist)
#end

Creates random number of given mean and maximum deviation, for example
rand_ext(1,0.2,Seed) gives a random number between 0.8 and 1.2
M - mean value
D - maximum deviation
Seed - (previously declared) random number seed identifier

#macro rand_ext(M,D,Seed)
        (M+(rand(Seed)-.5)*2*D)
#end


Post a reply to this message

From: Mike Weber
Subject: Re: A few useful macros
Date: 10 Dec 1998 10:19:19
Message: <366fe677.0@news.povray.org>
In 25 words or less, what does it do?


Margus Ramst wrote in message <01be2433$5a4ed380$7c01a8c0@b14.sise.ebs>...
>Here are some little macros that have recently saved me a lot of typing. I
>also submitted them to Twyst's #MacroScope (and I recommend you send your
>macros there, too)
>I hope you'll find these useful
>
>Improved interpolation function


Post a reply to this message

From: Margus Ramst
Subject: Re: A few useful macros
Date: 10 Dec 1998 16:25:37
Message: <36703AF1.343DDFA9@peak.edu.ee>
What does what do? The interpolation funcion?
Linear interpolation returns a value which is (proportionally) at the same
distance between TS and TE as GC is between GS and GE.
EXP > 1 makes the value "accelerate" as it goes from TS to TE, i.e. it changes a
little towards the start and a lot towards the end.
EXP < 1 makes the value "decelerate"

Sorry, lost count of the words ;)

Margus

Mike Weber wrote:
> 
> In 25 words or less, what does it do?
>


Post a reply to this message

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