POV-Ray : Newsgroups : povray.windows : How to generate sphere and cylinder with csv file : Re: How to generate sphere and cylinder with csv file Server Time
8 Feb 2023 08:09:38 EST (-0500)
  Re: How to generate sphere and cylinder with csv file  
From: Bald Eagle
Date: 7 Apr 2017 15:30:01
Message: <web.58e7e830ae95604b80403a200@news.povray.org>
"Jeff" <jef### [at] gmailcom> wrote:

> >>#macro S2C (Spherical)
>  // input - 2d vector: <Latitude, Longitude>
>  #local Lat = radians (Spherical.x);
>  #local Lon = radians (Spherical.y);
>  #local X = EarthRadius * cos(Lat) * cos(Lon);
>  #local Y = EarthRadius * cos(Lat) * sin(Lon);
>  #local Z = EarthRadius * sin(Lat);
> >>#local Cartesian = <X
>
> "" is there anything that i have to change in this part(above and below)? bcos i
> just realized i gave the wrong questions, i said "use the
> "lon" column as the Y position of the sphere, and "lat" column as the Z
> position?" , but its actually use the "lon" column as the X position of the
> sphere and "lat" as the Y positions of the sphere""

Well, since there's x, y, AND z positions of a sphere, and from the above
formulae x and y are computed from BOTH the lat and lon, that's a hard question
to answer - maybe think on it some more.

> "" HERE TOO ? ""

vide supra.

> ""and this part, do i have to do it just one of 'em? or what? ,

I don't understand - one of WHAT?

> i would like to
> change it like this (below) ""
>
> #declare Mode = "";
> #declare City = "";
> #declare ID = "";
> #declare Latitude = 0;
> #declare Longitude = 0;

Sure, that's fine - you're just changing my variable names - it's just a name
internal to the code - otherwise it's irrelevant - it could be called Q or
hhfdiuahfishv for all the computer cares.


> #declare Locations = 0;------> " what does this line do ? "
When you're going to use a variable for something, it needs to be initialized.
So I give it a value of zero.

> #fopen DataFile "LatLongData.txt" read
> #while (defined (DataFile))
>  #read (DataFile, Type, Location, ID, Latitude, Longitude)
>  #declare Locations = Locations + 1;
> #end
> #fclose DataFile
>
> "" this part, i would like to change it to like this (below)""
>
> // count locations for sizing array
> #declare Locations = 0; # i dont understand what is the "Locations" for????
> #fopen Nodes "nodes.csv" read
> #while (defined (Nodes))
>  #read (Nodes, Mode, City, ID, Longitude, Latitude)
>  #declare Locations = Locations + 1;
> #end
> #fclose Nodes

Again, just names.

> ---------------------------------------------------
> >>#declare _Type = array[Locations];
> #declare _Location = array[Locations];
> #declare _ID = array[Locations];
> #declare _Latitude = array[Locations];
> #declare _Longitude = array[Locations];
> #declare _XYZ = array[Locations];
>
> "" and i have problems to understand the block of codes above ""
> -----------------------------------------------------------------
I'm making arrays of values - like a spreadsheet.
rows of values, each with a "header" - the name of the array variable.
Every time I read a line in from the "CSV" file, I increased the "Locations"
counter by one, thus counting how many places you have to plot points.
Then I use that final value of the counter to dimension the array - to give it
the right size.   If Locations = 25, then each array - each "column" of values
in my "spreadsheet" has 25 slots.

(Don't freak out - arrays are kind of a pita the work with at times, and macros
can get a bit hairy too, but using them can make other tasks easier in the long
run)

Move your cursor to "array" and hit F1, and it should bring up the array section
in the Help files...
Or just Google  POV-Ray array and see what pops up.
(be conscious of what version you're looking at the documentation for)
I think the wiki is the most up to date location for documentation.


Post a reply to this message

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