POV-Ray : Newsgroups : povray.beta-test : [includes] VPow does not work Server Time
29 Jul 2024 10:26:41 EDT (-0400)
  [includes] VPow does not work (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Simon Adameit
Subject: [includes] VPow does not work
Date: 13 Jun 2002 16:36:53
Message: <3d090265@news.povray.org>
VPow in math.inc does not work, because pow only works with floats.

POV 3.5 RC6

Simon


Post a reply to this message

From: Rune
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 08:15:54
Message: <3d0b2ffa@news.povray.org>
Simon Adameit wrote:
> VPow in math.inc does not work, because pow only works with floats.

I presume it should work correct if it is changed to be like this below?

// Raises the components of a vector to a given power
#macro VPow(V, P) <pow(V.x, P), pow(V.y, P), pow(V.z, P)> #end
#macro VPow5D(V, P) <pow(V.x, P), pow(V.y, P), pow(V.z, P),
pow(V.filter, P), pow(V.transmit, P)> #end

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated May 20)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Warp
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 12:16:02
Message: <3d0b6842@news.povray.org>
Rune <run### [at] mobilixnetdk> wrote:
> // Raises the components of a vector to a given power
> #macro VPow(V, P) <pow(V.x, P), pow(V.y, P), pow(V.z, P)> #end
> #macro VPow5D(V, P) <pow(V.x, P), pow(V.y, P), pow(V.z, P),
> pow(V.filter, P), pow(V.transmit, P)> #end

  I wonder if there would be some ingenious way of detecting the type of
vector given as parameter and then creating the same type of vector as
result. This way one macro would suffice.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Rune
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 15:17:48
Message: <3d0b92dc@news.povray.org>
Warp wrote:
>   I wonder if there would be some ingenious way of
> detecting the type of vector given as parameter and
> then creating the same type of vector as result.
> This way one macro would suffice.

Yes, if it is possible to detect, I'd be interested. Especially since
there are several other macros in math.inc which also come in several
versions due to the various types of vectors.

But I don't know of such a method.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated May 20)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Warp
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 16:14:31
Message: <3d0ba027@news.povray.org>
Rune <run### [at] mobilixnetdk> wrote:
> Yes, if it is possible to detect, I'd be interested. Especially since
> there are several other macros in math.inc which also come in several
> versions due to the various types of vectors.

> But I don't know of such a method.

  I found a method. It may not be the fastest possible, but at least it works.

#macro Is5DVector(V)
  (strcmp(vstr(5, (V=V), "", 0, 0), "11111") = 0)
#end

#declare V1 = <1,2,3>;
#declare V2 = <4,5,6,7,8>;

#if(Is5DVector(V1)) #debug "yes, " #else #debug "no, " #end
#if(Is5DVector(V2)) #debug "yes" #else #debug "no" #end
#debug "\n"


-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Rune
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 16:19:47
Message: <3d0ba163@news.povray.org>
Warp wrote:
>   I found a method. It may not be the fastest possible, but at least
> it works.

That's great! Could you make it detect 2d (UV) vectors too? Of cpurse it
should then not return yes or no, but rather 2, 3 or 5.

Rune
--
3D images and anims, include files, tutorials and more:
Rune's World:  http://rsj.mobilixnet.dk (updated May 20)
POV-Ray Users: http://rsj.mobilixnet.dk/povrayusers/
POV-Ray Ring:  http://webring.povray.co.uk


Post a reply to this message

From: Warp
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 16:35:17
Message: <3d0ba505@news.povray.org>
Rune <run### [at] mobilixnetdk> wrote:
> That's great! Could you make it detect 2d (UV) vectors too? Of cpurse it
> should then not return yes or no, but rather 2, 3 or 5.

  Well, you could count the amount of 1's in the string. I think that should
be the correct answer (I haven't tried what happens when you do a (V=V) with
V being a 2D vector, but I think it should return <1,1>).
  Of course that's even slower because you'll have to call substr() at least
two times. Don't know if that matters in practice (after all, the string is
very short).

  Perhaps something like:

#macro VectorSize(V)
  #local tmp = vstr(5, (V=V), "", 0, 0);
  (2 + (asc(substr(tmp,3,1))=49) + 2*(asc(substr(tmp,5,1))=49))
#end

#declare V1 = <1,2>;
#declare V2 = <3,4,5>;
#declare V3 = <6,7,8,9,10>;

#debug concat("Size of V1: ", str(VectorSize(V1),0,0),
            "\nSize of V2: ", str(VectorSize(V2),0,0),
            "\nSize of V3: ", str(VectorSize(V3),0,0), "\n")


-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Warp
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 16:40:17
Message: <3d0ba631@news.povray.org>
Actually it can be made to work for floats as well:

#macro VectorSize(V)
  #local tmp = vstr(5, (V=V), "", 0, 0);
  (1 + (asc(substr(tmp,2,1))=49)+ (asc(substr(tmp,3,1))=49) +
   2*(asc(substr(tmp,5,1))=49))
#end

#declare V0 = 0;
#declare V1 = <1,2>;
#declare V2 = <3,4,5>;
#declare V3 = <6,7,8,9,10>;

#debug concat("Size of V0: ", str(VectorSize(V0),0,0),
            "\nSize of V1: ", str(VectorSize(V1),0,0),
            "\nSize of V2: ", str(VectorSize(V2),0,0),
            "\nSize of V3: ", str(VectorSize(V3),0,0), "\n")


-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Anders K 
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 16:49:42
Message: <3d0ba866$1@news.povray.org>
Why don't you add four-dimensional vectors, just to make it complete?

Anders

--
light_source{6#local D=#macro B(E)#macro A(D)#declare E=(E-#declare
C=mod(E D);C)/D;C#end#while(E)#if(A(8)=7)#declare D=D+2.8;#else#if(
C>2)}torus{1..2clipped_by{box{-2y}}rotate<1 0C>*90translate<D+1A(2)
*2+1#else}cylinder{0(C-v=1).2translate<D+C*A(2)A(4)#end-2 13>finish
{specular 1}pigment{rgb x}#end#end#end-8;1B(445000298)B(519053970)B
(483402386)B(1445571258)B(77778740)B(541684549)B(42677491)B(70)}


Post a reply to this message

From: Warp
Subject: Re: [includes] VPow does not work
Date: 15 Jun 2002 17:02:49
Message: <3d0bab78@news.povray.org>
Anders K. <and### [at] prostard2gcom> wrote:
> Why don't you add four-dimensional vectors, just to make it complete?

  Yes, why not?

#macro VectorSize(V)
  #local tmp = vstr(5, (V=V), "", 0, 0);
  (1 + (asc(substr(tmp,2,1))=49) +
       (asc(substr(tmp,3,1))=49) +
       (asc(substr(tmp,4,1))=49) +
       (asc(substr(tmp,5,1))=49))
#end

#declare V1 = 0;
#declare V2 = <1,2>;
#declare V3 = <3,4,5>;
#declare V4 = <3,4,5,6>;
#declare V5 = <6,7,8,9,10>;

#debug concat("Size of V1: ", str(VectorSize(V1),0,0),
            "\nSize of V2: ", str(VectorSize(V2),0,0),
            "\nSize of V3: ", str(VectorSize(V3),0,0),
            "\nSize of V4: ", str(VectorSize(V4),0,0),
            "\nSize of V5: ", str(VectorSize(V5),0,0), "\n")


-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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