POV-Ray : Newsgroups : povray.general : String to vector function? Server Time
15 Jun 2024 19:22:25 EDT (-0400)
  String to vector function? (Message 1 to 3 of 3)  
From: Stephen
Subject: String to vector function?
Date: 21 Oct 2014 09:52:13
Message: <5446650d$1@news.povray.org>
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


Post a reply to this message

From: Bald Eagle
Subject: Re: String to vector function?
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

From: Stephen
Subject: Re: String to vector function?
Date: 21 Oct 2014 14:15:32
Message: <5446a2c4$1@news.povray.org>
On 21/10/2014 15:34, Bald Eagle wrote:
> Will strings.inc work?
> Parse_String(String):

Duh!

I am working my way through someone else's code. StephenS IIRC.
And he used that macro about 20 lines before.

Thanks for jogging my memory. I could not code my way out of a wet paper 
bag. :-(


-- 

Regards
     Stephen


Post a reply to this message

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