POV-Ray : Newsgroups : povray.advanced-users : explicit vector type-casting in pov Server Time
25 Dec 2024 21:33:32 EST (-0500)
  explicit vector type-casting in pov (Message 1 to 3 of 3)  
From: Tek
Subject: explicit vector type-casting in pov
Date: 17 Oct 2006 20:10:59
Message: <45357113@news.povray.org>
I have a vector with 4 components and I want to use the first 3 (xyz) as a 
position, in a sphere sweep. But pov gives me "vector expected but color 
expression found". As far as I can see the only way round this is the very 
ugly <V.x,V.y,V.z>, because expresions like <1,1,1>*V start by promoting 
<1,1,1> to a 4-component vector!

So, am I missing something? Is there some easy short hand to tell pov that 
it's allowed to demote the vector to the appropriate type? really I want 
something as simple as V.xyz, or even just V with it being implicit. Why 
doesn't pov like 4D vectors for a 3D property, when x, y, and z are well 
defined?

Anyway, I'll do it the long winded way until someone educates me on this 
subject! ;-)

-- 
Tek
http://evilsuperbrain.com


Post a reply to this message

From: Warp
Subject: Re: explicit vector type-casting in pov
Date: 17 Oct 2006 20:20:04
Message: <45357334@news.povray.org>
Tek <tek### [at] evilsuperbraincom> wrote:
> So, am I missing something?

  No.

-- 
                                                          - Warp


Post a reply to this message

From: Mike Williams
Subject: Re: explicit vector type-casting in pov
Date: 18 Oct 2006 00:26:36
Message: <vdB4IBAMuaNFFwi4@econym.demon.co.uk>
Wasn't it Tek who wrote:
>I have a vector with 4 components and I want to use the first 3 (xyz) as a 
>position, in a sphere sweep. But pov gives me "vector expected but color 
>expression found". As far as I can see the only way round this is the very 
>ugly <V.x,V.y,V.z>, because expresions like <1,1,1>*V start by promoting 
><1,1,1> to a 4-component vector!
>
>So, am I missing something? Is there some easy short hand to tell pov that 
>it's allowed to demote the vector to the appropriate type? really I want 
>something as simple as V.xyz, or even just V with it being implicit. Why 
>doesn't pov like 4D vectors for a 3D property, when x, y, and z are well 
>defined?
>
>Anyway, I'll do it the long winded way until someone educates me on this 
>subject! ;-)

You can write a little macro, like

     #macro v3(a)  <a.x, a.y, a.z>  #end

Then use  v3(V)  wherever you wanted to use  V.xyz

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

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