|  |  | High!
I'm trying to set up an array for the position vectors of seven planets, 
  but whenever I start the script, I get the error message
File: E:\Povscn\system.pov  Line: 20
#while (a<7)
   PlanetPoss[a] <----ERROR
Parse Error: Expected 'object or directive', float function 'float 
identifier' found instead
Here is the code:
#declare Planets=array[3][7]
{
   { 3750000, 19400000, 40100000, 104720000, 201000000, 338000000, 
949000000 }
   { 1289, 2560, 12784, 63879, 34974, 51075, 10451 }
   { 12, 90, 104, 56, 32, 253, 4 }
}
#declare PlanetPoss=array[7] { 0, 0, 0, 0, 0, 0, 0 }
#declare a=0;
#while (a<7)
   PlanetPoss[a]=StarPos+Planets[0][a]*<sin(Planets[2][a]*(pi/180)), 0, 
cos(Planets[2][a]*(pi/180))>
   #declare a=a+1;
#end
(astronomers: please forgive me that I, for the time being, assumed 
circular orbits!)
See you in Khyberspace!
Yadgar
Post a reply to this message
 |  | 
|  |  | Yadgar wrote:
> High!
Hi
> I'm trying to set up an array for the position vectors of seven planets, 
>  but whenever I start the script, I get the error message
> 
> 
> File: E:\Povscn\system.pov  Line: 20
> #while (a<7)
> 
>   PlanetPoss[a] <----ERROR
> 
> Parse Error: Expected 'object or directive', float function 'float 
> identifier' found instead
> 
> Here is the code:
> 
> #declare Planets=array[3][7]
> {
>   { 3750000, 19400000, 40100000, 104720000, 201000000, 338000000, 
> 949000000 }
>   { 1289, 2560, 12784, 63879, 34974, 51075, 10451 }
>   { 12, 90, 104, 56, 32, 253, 4 }
> }
> 
> #declare PlanetPoss=array[7] { 0, 0, 0, 0, 0, 0, 0 }
> #declare a=0;
> #while (a<7)
>   PlanetPoss[a]=StarPos+Planets[0][a]*<sin(Planets[2][a]*(pi/180)), 0, 
> cos(Planets[2][a]*(pi/180))>
>   #declare a=a+1;
> #end
...
Yadgar, you get that error message because that line is
missing a #declare statement.
Here are some further comments:
- The line also lacks a semicolon at the end.
- You have forgotten to initialize the StarPos variable.
- You cannot assign a vector to elements in an array that
   already contains float values.
- You should avoid making variable names that consists of
   lowercase letters only.
- POV-Ray has a radians() function that converts from
   degrees to radians.
- Your vector expression with cos() and sin() functions
   can be replaced with a vrotate() statement.
Some code that works:
#declare Planets =
   array[3][7] {
     { 3.75e6, 1.94e7, 4.01e7, 1.0472e8, 2.01e8, 3.38e8, 9.49e8 }
     { 1289, 2560, 12784, 63879, 34974, 51075, 10451 }
     { 12, 90, 104, 56, 32, 253, 4 }
   }
#declare StarPos = <0, 0, 0>;
#declare PlanetPos = array[7]
#declare A = 0;
#while (A < 7)
   #declare PlanetPos[A] =
     StarPos + Planets[0][A]*vrotate(z, Planets[2][A]*y);
   #declare A = A + 1;
#end // while
-- 
Tor Olav
http://subcube.net
http://subcube.com
Post a reply to this message
 |  |