POV-Ray : Newsgroups : povray.general : Q: vector promotion Server Time
15 Nov 2024 23:21:16 EST (-0500)
  Q: vector promotion (Message 1 to 4 of 4)  
From: Margus Ramst
Subject: Q: vector promotion
Date: 12 Nov 1998 15:25:25
Message: <364B446C.923BA800@peak.edu.ee>
Hi all,

I've got this problem (not serious, but got me wondering)...

When a macro param is a vector (e.g. I use dot operators on it), it seems I
can't use a float identifier to represent it - it doesn't get promoted to a
vector. Example:

#macro MyMacro(Vector)
	(Vector.x + Vector.y + Vector.z)
#end

MyMacro(<3,3,3>) is OK but
MyMacro(3) gets an error

Why is the float not promoted to a vector? Is it because POV can't tell the type
of a macro param?

Margus


Post a reply to this message

From: PoD
Subject: Re: Q: vector promotion
Date: 12 Nov 1998 17:54:18
Message: <364B671C.F8C@merlin.net.au>
Margus Ramst wrote:
> 
> Hi all,
> 
> I've got this problem (not serious, but got me wondering)...
> 
> When a macro param is a vector (e.g. I use dot operators on it), it seems I
> can't use a float identifier to represent it - it doesn't get promoted to a
> vector. Example:
> 
> #macro MyMacro(Vector)
>         (Vector.x + Vector.y + Vector.z)
> #end
> 
> MyMacro(<3,3,3>) is OK but
> MyMacro(3) gets an error
> 
> Why is the float not promoted to a vector? Is it because POV can't tell the type
> of a macro param?
> 
> Margus

The input parameter becomes whatever type is passed to it, so if you
give it a float value, it is a float type variable.
You could try

#macro MyMacro(InputVector)
#local Vector=InputVector*<1,1,1>;
...
#end

Cheers, PoD


Post a reply to this message

From: Ronald L  Parker
Subject: Re: Q: vector promotion
Date: 12 Nov 1998 20:31:20
Message: <364d8bf7.163825061@news.povray.org>
On Thu, 12 Nov 1998 22:26:21 +0200, Margus Ramst <mar### [at] peakeduee>
wrote:

>Why is the float not promoted to a vector? Is it because POV can't tell the type
>of a macro param?

Right.  You can force the promotion by multiplying it by <1,1,1> or
adding it to <0,0,0>


Post a reply to this message

From: Margus Ramst
Subject: Re: Q: vector promotion
Date: 13 Nov 1998 03:47:56
Message: <364BF22F.8EA36D6A@peak.edu.ee>
Ronald L. Parker wrote:
> Right.  You can force the promotion by multiplying it by <1,1,1> or
> adding it to <0,0,0>

Thanks, this is the solution.
A remark, though: you can't redefine a float identifier as a vector identifier,
so this has to be done by declaring a new variable.

Margus


Post a reply to this message

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