POV-Ray : Newsgroups : povray.general : String to vector function? : Re: String to vector function? Server Time
22 Jun 2024 06:52:44 EDT (-0400)
  Re: String to vector function?  
From: Bald Eagle
Date: 21 Oct 2014 10:35:01
Message: <web.54466eb9e491cc245e7df57c0@news.povray.org>
Stephen <mca### [at] aolcom> wrote:
> I have a string that looks like a vector. E.g. <12.34, 0, 567>
> How can I turn it into a real vector so it can be operated on?
>
> Example.
> MyString = "<12.34, 0, 567>"
>
> /Magic function/
>
> My vector = <12.34, 0, 567>
>
> --
>
> Regards
>      Stephen


Will strings.inc work?
Parse_String(String): This macro takes a string, writes it to a file, and then
includes that file. This has the effect of parsing that string:
"Parse_String("MyColor")" will be seen by POV-Ray as "MyColor".

So maybe try:
Parse_String ("<12.34, 0, 567>")

//==============================Bald Eagle====================================
cylinder{z,z*1.1,.65 pigment{cylindrical rotate x*90 color_map{[0 rgb<1,.2,0>]
[1 rgb xy]}}}#macro C(D,S,F,M)sin(radians(D+(F*90)+(i*S)))*A+M#end#local L=.9;
#local A=0.3125;#local i=0;#local T=.014;#macro
R(X,Y,D,S,M,N)cylinder{<X,Y,L>,<C(D,S,1,M),C(D,S,0,N),L>T}#end#macro
V(X,Y,Z,P,J,K,Q,U)cone{<X,Y,Z>P<J,K,Z>Q pigment{rgb U}}#end#while(i<8)#local
F=R(-0.243,.113,170,20,-.415,.069) #local
W=difference{R(-.172+(i/80),.328,250,5,-0.18,0.18)sphere {<-.14,.22,L>A/2.4}}
union{object{F}object{F scale-x*1}object{W}object{W scale-x*1}
cylinder{<.004,.095,L>,<-.007,-.18,L>,.1}pigment{Brown}}
cylinder{<-.008,-0.03,L>,<C(240,10,1,-.028),C(240,10,0,-.09),L>.014 pigment{rgb
1}}V(-.01,.095,L,.08,.003,.28,.021,1)V(-.001,.2,.85,0,.01,.26,.028,0)
V(.019,.23,.83,0,.026,.25,.01,xy)sphere{<.005,.25,.82>.002 pigment{rgb
1}}#declare i=i+1;#end
//=============================================================================


Post a reply to this message

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