POV-Ray : Newsgroups : povray.windows : How to generate sphere and cylinder with csv file Server Time
9 Nov 2026 19:11:12 EST (-0500)
  How to generate sphere and cylinder with csv file (Message 1 to 31 of 31)  
From: Jeff
Subject: How to generate sphere and cylinder with csv file
Date: 27 Mar 2017 08:20:01
Message: <web.58d90246d665dbbed33c50560@news.povray.org>
so, i have csv files that i would like to use to do the visualization.its
something like below:

mode country/city ID         lon         lat
bus CN/Beijing bus2382659521 116.4093833 39.9067192
bus CN/Beijing bus1636776952 116.3039935 39.8888451
rail CN/Beijing rail269996666 116.4209908 39.9016416
rail CN/Beijing rail1419861955 116.3465335 39.9430318
subway CN/Beijing subway339089932 116.3572162 39.8980033
subway CN/Beijing subway339086386 116.3041387 39.9061679
tram CN/Beijing tram1408143389 116.3920808 39.8904203
tram CN/Beijing tram1408143387 116.3917507 39.896844


so, i want to generate some spheres to represent the information in the csv file
above,
how do i generate different color of spheres for different mode, and use the
"lon" column as the Y position of the sphere, and "lat" column as the Z
position?



and the other csv file is something like this:

mode Source           Target            length
bus bus332263578   bus2052937452            59.34930975
bus bus268389450   bus268389107            101.9938894
rail rail539260172   rail1182599524           571.7497256
rail rail1182599524   rail273113548            568.8268748
subway subway245154338   subway245143068          81.85897267
subway subway336935693   subway3369356929         99.88085188

then i use these information to generate cylinder and connect the it to sphere
accordingly by using the "Source" column and "Target" column and the "length"
column as the length of the cylinders.

can someone help me please?


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 27 Mar 2017 10:15:00
Message: <web.58d91d7eae95604bc437ac910@news.povray.org>
"Jeff" <jef### [at] gmailcom> wrote:

> so, i want to generate some spheres to represent the information in the csv file
> above,
> how do i generate different color of spheres for different mode,

So, real quick,

#include "colors.inc"
#if (variable = "bus")
  #declare Color = pigment {Red};
#else if (variable2 = "rail")

#else
#end

Write your data to a text file, use the #open, #read directives to read the
values in.

#declare a Y variable as that value.
same for the Z variable  (notice both are Uppercase)

searching for:  #read #write data from file
pulls up the following, with lots more

http://news.povray.org/povray.general/thread/%3Cweb.4d05993a67d8c71bd6b9b2630@news.povray.org%3E/?ttop=357624&toff=50

http://news.povray.org/povray.general/thread/%3Cweb.43886ab1919621bdcce6fd2b0@news.povray.org%3E/?ttop=330491&toff=1350




> then i use these information to generate cylinder and connect the it to sphere
> accordingly by using the "Source" column and "Target" column and the "length"
> column as the length of the cylinders.

Don't worry about the length, just use the coordinates of the 2 spheres as the
endpoint coordinates of the cylinder.

You're probably going to have to convert your values from long/lat to some
meaningful x,y,z coordinates (polar to Cartesian)


Post a reply to this message

From: Mike Horvath
Subject: Re: How to generate sphere and cylinder with csv file
Date: 27 Mar 2017 23:47:43
Message: <58d9dcdf$1@news.povray.org>
I usually do conversions like this in Excel or using some external 
script. You can mix the numbers with short strings of text to generate 
valid POV-Ray code.


Mike


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 28 Mar 2017 07:25:00
Message: <web.58da47d9ae95604b4de507a60@news.povray.org>
From: "Jeff" <jef### [at] gmailcom>
Newsgroups: povray.windows
Subject: Re: How to generate sphere and cylinder with csv file

"Bald Eagle" <cre### [at] netscapenet> wrote:
> So, real quick,
>
> #include "colors.inc"
> #if (variable = "bus")
>   #declare Color = pigment {Red};
> #else if (variable2 = "rail")
>
> #else
> #end
>
> Write your data to a text file, use the #open, #read directives to read the
> values in.
>
> #declare a Y variable as that value.
> same for the Z variable  (notice both are Uppercase)
>
> searching for:  #read #write data from file
> pulls up the following, with lots more
>
>http://news.povray.org/povray.general/thread/%3Cweb.4d05993a67d8c71bd6b9b2630@news.povray.org%3E/?ttop=357624&toff=50
>
>
http://news.povray.org/povray.general/thread/%3Cweb.43886ab1919621bdcce6fd2b0@news.povray.org%3E/?ttop=330491&toff=13
50

>
> Don't worry about the length, just use the coordinates of the 2 spheres as the
> endpoint coordinates of the cylinder.
>
> You're probably going to have to convert your values from long/lat to some
> meaningful x,y,z coordinates (polar to Cartesian)

hi, if i open the .csv file , and save it as .txt file, will that do the
conversion? and i have like 1000+ sphere that i need to generate from the data,
is there any efficient way to do it, instead of write down the sphere position?
so, is this the way to do it? hey, i want to talk more detail about, and i need
your help. here is my email: jef### [at] gmailcom. thanks before :)


#include "colors.inc"
#declare myImage = image{ png "C:\\Users\\Jeff\\Desktop\\beijing.png" }

#fopen nodesfile "nodes.txt" read
#fopen linksfile "links.txt" read
  #while (defined(nodesfile))
    #read (nodesfile,Var1,Var2,Var3,Var4)


#if (Var1 = "bus")
    #declare Color = pigment {Red};
#else if (Var2 = "subway")
    #declare Color = pigment {Green};
#else if (Var3 = "rail")
    #declare Color = pigment {Blue};
#else (Var4 = "tram")
    #declare Color = pigment {Yellow};
#end

camera
{ location <0,0,-10>
  look_at 0
  rotate <0,clock*360,0>
}

light_source    {
                <10,10,-10>
                color White
                }


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 28 Mar 2017 08:00:00
Message: <web.58da4fecae95604bc437ac910@news.povray.org>
"Jeff" <jef### [at] gmailcom> wrote:

> hi, if i open the .csv file , and save it as .txt file, will that do the
> conversion?

The .csv file is essentially a text file in exactly the format that POV-Ray
needs it to be in.  "Comma Separated Values" = CSV

> and i have like 1000+ sphere that i need to generate from the data,

Not a problem - I've made scenes with millions.

> is there any efficient way to do it, instead of write down the sphere position?

Yes, that's why you're automating the process by reading in the values from an
existing file.
I'd start with a small fragment of the file - say 10-50 entries or so, and
output all of the variables you read in and calculate to the #ebug stream so
that you're sure about what you're working with, and passing on to POV-Ray.

I generally define a Verbose variable, then use
#if (Verbose)
     #debug "Debugging on \n"
     etc
#end
so that I'm not forever commenting and uncommenting debugging tools.

> #include "colors.inc"
> #declare myImage = image{ png "C:\\Users\\Jeff\\Desktop\\beijing.png" }

try:
#declare myImage = pigment {image_map {png "C:/Users/Jeff/Desktop/beijing.png"
}}
#declare Resolution = max_extent (myImage);
#declare ImageHeight = Resolution.y;
#declare ImageWidth = Resolution.x;

Then make a flat box:  box {0, 1, translate -0.5 pigment {myImage} scale
<Resolution.x, Resolution.y, 1>}


> #fopen nodesfile "nodes.txt" read
> #fopen linksfile "links.txt" read
>   #while (defined(nodesfile))
>     #read (nodesfile,Var1,Var2,Var3,Var4)
>
>
> #if (Var1 = "bus")
>     #declare Color = pigment {Red};
> #else if (Var2 = "subway")
>     #declare Color = pigment {Green};
> #else if (Var3 = "rail")
>     #declare Color = pigment {Blue};
> #else (Var4 = "tram")
>     #declare Color = pigment {Yellow};
> #end
>
> camera
> { location <0,0,-10>
>   look_at 0
>   rotate <0,clock*360,0>
> }

I'm not sure why you're using the Clock variable in your camera definition,
unless you plan on animating this later.
Probably gonna have to move that camera WAY back in the -z direction.
I'd also probably use an orthographic camera, and ambient_light to get aa pretty
flat, evenly lit scene, at least at the beginning.

> light_source    {
>                 <10,10,-10>
>                 color White
>                 }


Post a reply to this message

From: clipka
Subject: Re: How to generate sphere and cylinder with csv file
Date: 28 Mar 2017 09:40:53
Message: <58da67e5$1@news.povray.org>
Am 28.03.2017 um 13:58 schrieb Bald Eagle:
> "Jeff" <jef### [at] gmailcom> wrote:
> 
>> hi, if i open the .csv file , and save it as .txt file, will that do the
>> conversion?
> 
> The .csv file is essentially a text file in exactly the format that POV-Ray
> needs it to be in.  "Comma Separated Values" = CSV

Accordin to the OP it isn't really CSV, but rather tab-separated (or
blank-separated?) values.

These are /not/ ideally suited for the use with `#read`.


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 28 Mar 2017 10:15:01
Message: <web.58da6f56ae95604bc437ac910@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> Accordin to the OP it isn't really CSV, but rather tab-separated (or
> blank-separated?) values.
>
> These are /not/ ideally suited for the use with `#read`.

Right on.
It looks like space or tab-delimited.
Perhaps the OP could link to the source.

Opening in Excel or OpenOffice and saving as true CSV ought to do it.

He's also going to need to fix that ID string with something like (untested):

#declare ID = substr(S3,strlen(S1),strlen(S3)-strlen(S1))

where S1 is the mode, and S3 is the ID.

(BTW, I didn't see a dedicated entry for "strlen()" in the F1 documentation
section on String Functions. Perhaps I overlooked it...)


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 29 Mar 2017 10:50:01
Message: <web.58dbc93eae95604b4de507a60@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> clipka <ano### [at] anonymousorg> wrote:
> > Accordin to the OP it isn't really CSV, but rather tab-separated (or
> > blank-separated?) values.
> >
> > These are /not/ ideally suited for the use with `#read`.
>
> Right on.
> It looks like space or tab-delimited.
> Perhaps the OP could link to the source.
>
> Opening in Excel or OpenOffice and saving as true CSV ought to do it.
-- so, i did try to run the code , and it shows me the list of information from
the nodes.csv file. so, its probably means it could work with it.


> He's also going to need to fix that ID string with something like (untested):
>
> #declare ID = substr(S3,strlen(S1),strlen(S3)-strlen(S1))
>
> where S1 is the mode, and S3 is the ID.
>
> (BTW, I didn't see a dedicated entry for "strlen()" in the F1 documentation
> section on String Functions. Perhaps I overlooked it...)
-- they are dedicated , but i just put some of it, because they are not in a
organized order. so, i just pick some samples from it.


#include "colors.inc"
#fopen nodesfile "C:\\Users\\Jeff\\Desktop\\nodes.csv" read
#fopen linksfile "C:\\Users\\Jeff\\Desktop\\links.csv" read
  #while (defined(nodesfile))
    #read (nodesfile,Var1,Var2,Var3,Var4)
#declare myImage = pigment {image_map {png "C:/Users/Jeff/Desktop/beijing.png"
}}
#declare Resolution = max_extent (myImage);
#declare ImageHeight = Resolution.y;
#declare ImageWidth = Resolution.x;
box {0, 1, translate -0.5 pigment {myImage} scale
<Resolution.x, Resolution.y, 1>}



#if (Verbose)
     #debug "Debugging on \n"
     etc
#end
#if (Var1 = "bus")
    #declare Color = pigment {Red};
#else if (Var2 = "subway")
    #declare Color = pigment {Green};
#else if (Var3 = "rail")
    #declare Color = pigment {Blue};
#else (Var4 = "tram")
    #declare Color = pigment {Yellow};
#end

camera {
   orthographic
   location <-1000,0,0>
   look_at 0
   rotate <0,clock*360,0>
   }

light_source    {
                <10,10,-1000>
                color White
                }

jeff.federick93@(gmail.com)is my email.


Post a reply to this message

From: clipka
Subject: Re: How to generate sphere and cylinder with csv file
Date: 29 Mar 2017 12:43:45
Message: <58dbe441@news.povray.org>
Am 29.03.2017 um 16:48 schrieb Jeff:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> clipka <ano### [at] anonymousorg> wrote:
>>> Accordin to the OP it isn't really CSV, but rather tab-separated (or
>>> blank-separated?) values.
>>>
>>> These are /not/ ideally suited for the use with `#read`.
>>
>> Right on.
>> It looks like space or tab-delimited.
>> Perhaps the OP could link to the source.
>>
>> Opening in Excel or OpenOffice and saving as true CSV ought to do it.
> -- so, i did try to run the code , and it shows me the list of information from
> the nodes.csv file. so, its probably means it could work with it.

IIRC, if your file format does not contain commas, the following may be
misinterpreted:

    47 11
    42 -12

While the first line would be interpreted as the individual numbers 47
and 11, the second line might be misinterpreted as the single number 30
(the result of the expression `42-12`).


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 29 Mar 2017 15:20:00
Message: <web.58dc085aae95604bc437ac910@news.povray.org>
Here ya go.

Pay attention to the data format (see comments)

Needs scaling to fit (a) on the screen better and (b) on top of your image to
match locations

Better code would have methods built in to catch and reject erroneous data, etc.

But here are the basics.

=========================================================================

// Persistence of Vision Ray Tracer version 3.7
// Scene Description Language (SDL)
//      File: Latitude / Longitude Mapping
//      Version: 1.0
//      Last updated: 29-Mar-2017
//      Description: Read Latitude and Longitude from file and connect points on
map
//
// Author:   Bill Walker "Bald Eagle", 2017
// email:    see posts in news.povray.org
//
//------------------------------------------------------------------------

#version 3.7;

global_settings {
 assumed_gamma 1.0
 #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
 ambient_light rgb <1, 1, 1> // <======== flat, even illumination
}

#include "colors.inc"

camera {
 location <0, 0, -1>
 right    x*image_width/image_height
 look_at <0, 0, 0>
}

light_source{ <50, 50, -100>  color rgb <1, 1, 1>}

// #declare EarthRadius = 6367; //radius in km
#declare EarthRadius = 6367*0.621371; //radius in mi

#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, Y, Z>;
 Cartesian;
#end // end macro S2C


#macro C2S (Cartesian)

 #local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
2));
 #local Lat = degrees (asin (Cartesian.z / R));
 #local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
 #local LatLon = <Lat, Lon>;
 LatLon;
#end // end macro C2S

//  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
//    etc.
#declare Type = "";
#declare Location = "";
#declare ID = "";
#declare Latitude = 0;
#declare Longitude = 0;

// count locations for sizing array
#declare Locations = 0;
#fopen DataFile "LatLongData.txt" read
#while (defined (DataFile))
 #read (DataFile, Type, Location, ID, Latitude, Longitude)
 #declare Locations = Locations + 1;
#end
#fclose DataFile

#declare _Type = array[Locations];
#declare _Location = array[Locations];
#declare _ID = array[Locations];
#declare _Latitude = array[Locations];
#declare _Longitude = array[Locations];
#declare _XYZ = array[Locations];

// input data into array
#declare Datapoint = 0;
#fopen DataFile "LatLongData.txt" read
#while (defined (DataFile))
 #read (DataFile, Type, Location, ID, Latitude, Longitude)

 #declare _Type [Datapoint] = Type;
 #declare _Location [Datapoint] = Location;
 #declare _ID [Datapoint] = ID;
 #declare _Latitude [Datapoint] = Latitude;
 #declare _Longitude [Datapoint] = Longitude;
 #declare _XYZ [Datapoint] = S2C (<_Latitude[Datapoint],
_Longitude[Datapoint]>);
 #declare Datapoint = Datapoint + 1;
#end
#fclose DataFile

#declare Marker = 0.25;
#declare Line = 0.05;
#declare Linecolor = pigment {Magenta};

#for (Point, 0, Locations-1)

 #if (Type = "bus")
  #declare Color = pigment {Red};
 #elseif (Type = "subway")
  #declare Color = pigment {Green};
 #elseif (Type = "rail")
  #declare Color = pigment {Blue};
 #elseif (Type = "tram")
  #declare Color = pigment {Yellow};
 #else
  #debug "Unidentified Location Type.  \n"
  #declare Color = pigment {White};
 #end

 #declare S = 1; //<0.1, 0.1, 1/4000>;
 #declare T = <1350, 1130, -3500>;

 sphere {0, Marker pigment {Color} translate _XYZ[Point]*S translate T}

 #if (Point > 0)
  cylinder {LastPoint*S, _XYZ[Point]*S, Line pigment {Linecolor} translate T}
 #end // end if

 #debug concat( "Vector = ", vstr(3, _XYZ[Point]*S, ", ", 3, 0), " \n")

 #declare LastPoint = _XYZ[Point];

#end // end for Point


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 30 Mar 2017 07:40:00
Message: <web.58dcedd1ae95604bc437ac910@news.povray.org>
In the wee hours, I was thinking it would be nice to be able to generate a
Delaunay triangulation of data like this.


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 30 Mar 2017 13:05:01
Message: <web.58dd3a58ae95604b653b97b10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> Here ya go.
>
> Pay attention to the data format (see comments)
>
> Needs scaling to fit (a) on the screen better and (b) on top of your image to
> match locations
>
> Better code would have methods built in to catch and reject erroneous data, etc.
>
> But here are the basics.
>
> =========================================================================
>
> // Persistence of Vision Ray Tracer version 3.7
> // Scene Description Language (SDL)
> //      File: Latitude / Longitude Mapping
> //      Version: 1.0
> //      Last updated: 29-Mar-2017
> //      Description: Read Latitude and Longitude from file and connect points on
> map
> //
> // Author:   Bill Walker "Bald Eagle", 2017
> // email:    see posts in news.povray.org
> //
> //------------------------------------------------------------------------
>
> #version 3.7;
>
> global_settings {
>  assumed_gamma 1.0
>  #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
>  ambient_light rgb <1, 1, 1> // <======== flat, even illumination
> }
>
> #include "colors.inc"
>
> camera {
>  location <0, 0, -1>
>  right    x*image_width/image_height
>  look_at <0, 0, 0>
> }
>
> light_source{ <50, 50, -100>  color rgb <1, 1, 1>}
>
> // #declare EarthRadius = 6367; //radius in km
> #declare EarthRadius = 6367*0.621371; //radius in mi
>
> #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, Y, Z>;
>  Cartesian;
> #end // end macro S2C
>
>
> #macro C2S (Cartesian)
>
>  #local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
> 2));
>  #local Lat = degrees (asin (Cartesian.z / R));
>  #local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
>  #local LatLon = <Lat, Lon>;
>  LatLon;
> #end // end macro C2S
>
> //  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
> //    etc.
> #declare Type = "";
> #declare Location = "";
> #declare ID = "";
> #declare Latitude = 0;
> #declare Longitude = 0;
>
> // count locations for sizing array
> #declare Locations = 0;
> #fopen DataFile "LatLongData.txt" read
> #while (defined (DataFile))
>  #read (DataFile, Type, Location, ID, Latitude, Longitude)
>  #declare Locations = Locations + 1;
> #end
> #fclose DataFile
>
> #declare _Type = array[Locations];
> #declare _Location = array[Locations];
> #declare _ID = array[Locations];
> #declare _Latitude = array[Locations];
> #declare _Longitude = array[Locations];
> #declare _XYZ = array[Locations];
>
> // input data into array
> #declare Datapoint = 0;
> #fopen DataFile "LatLongData.txt" read
> #while (defined (DataFile))
>  #read (DataFile, Type, Location, ID, Latitude, Longitude)
>
>  #declare _Type [Datapoint] = Type;
>  #declare _Location [Datapoint] = Location;
>  #declare _ID [Datapoint] = ID;
>  #declare _Latitude [Datapoint] = Latitude;
>  #declare _Longitude [Datapoint] = Longitude;
>  #declare _XYZ [Datapoint] = S2C (<_Latitude[Datapoint],
> _Longitude[Datapoint]>);
>  #declare Datapoint = Datapoint + 1;
> #end
> #fclose DataFile
>
> #declare Marker = 0.25;
> #declare Line = 0.05;
> #declare Linecolor = pigment {Magenta};
>
> #for (Point, 0, Locations-1)
>
>  #if (Type = "bus")
>   #declare Color = pigment {Red};
>  #elseif (Type = "subway")
>   #declare Color = pigment {Green};
>  #elseif (Type = "rail")
>   #declare Color = pigment {Blue};
>  #elseif (Type = "tram")
>   #declare Color = pigment {Yellow};
>  #else
>   #debug "Unidentified Location Type.  \n"
>   #declare Color = pigment {White};
>  #end
>
>  #declare S = 1; //<0.1, 0.1, 1/4000>;
>  #declare T = <1350, 1130, -3500>;
>
>  sphere {0, Marker pigment {Color} translate _XYZ[Point]*S translate T}
>
>  #if (Point > 0)
>   cylinder {LastPoint*S, _XYZ[Point]*S, Line pigment {Linecolor} translate T}
>  #end // end if
>
>  #debug concat( "Vector = ", vstr(3, _XYZ[Point]*S, ", ", 3, 0), " \n")
>
>  #declare LastPoint = _XYZ[Point];
>
> #end // end for Point

Thank you so much, really appreciate it :)


Post a reply to this message

From: Alain
Subject: Re: How to generate sphere and cylinder with csv file
Date: 30 Mar 2017 16:19:13
Message: <58dd6841$1@news.povray.org>
Le 17-03-29 à 15:17, Bald Eagle a écrit :
> Here ya go.
>
> Pay attention to the data format (see comments)
>
> Needs scaling to fit (a) on the screen better and (b) on top of your image to
> match locations
>
> Better code would have methods built in to catch and reject erroneous data, etc.
>
> But here are the basics.
>
> =========================================================================
>
> // Persistence of Vision Ray Tracer version 3.7
> // Scene Description Language (SDL)
> //      File: Latitude / Longitude Mapping
> //      Version: 1.0
> //      Last updated: 29-Mar-2017
> //      Description: Read Latitude and Longitude from file and connect points on
> map
> //
> // Author:   Bill Walker "Bald Eagle", 2017
> // email:    see posts in news.povray.org
> //
> //------------------------------------------------------------------------
>
> #version 3.7;
>
> global_settings {
>  assumed_gamma 1.0
>  #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
>  ambient_light rgb <1, 1, 1> // <======== flat, even illumination
> }
>
This is the default value for ambient_lights. So, it's prety useless for 
what you want to do.

Beter to use :
#default{finish{ambient 1 diffuse 0}}
This statement is not a in it's place inside the global_settings block.

Even beter. Don't play with ambient, but, instead, use the +q0 switch.
With that switch, all lights are ignored, as well as reflections and 
refraction, only full ambient pigments are used.
You also get the advantage that it render faster.


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 1 Apr 2017 01:50:00
Message: <web.58df3f01ae95604b653b97b10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> In the wee hours, I was thinking it would be nice to be able to generate a
> Delaunay triangulation of data like this.

Hi, i want to a question.
1. is it possible to use pictures as a plane ? so, i want to use the pictures as
the layers, but because i have 4 mode in this file, i need 4 layers for it.
so, each layer will have their own picture as the plane.

example picture:
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTsQ_AU
IBigB&biw=1536&bih=724

i want to have 4 vertical layers and align to each other.


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 1 Apr 2017 02:05:00
Message: <web.58df4252ae95604b653b97b10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> In the wee hours, I was thinking it would be nice to be able to generate a
> Delaunay triangulation of data like this.

another question is , is it possible to rotate, zoom in and zoom out freely in
POV-RAY?

i mean, when you have thousands or even millions nodes and links and its so many
of em, that you need to put your camera far far away, but then the nodes and
links are sooooo small.

so, how to deliver the information effectively that people can see all of the
nodes and links, but at the same time its not too small (or too hard) to see?
is there any solutions to solve this problem in POV-RAY?

so, how did you do it in your experience that you have done it with millions of
em?


Post a reply to this message

From: Stephen
Subject: Re: How to generate sphere and cylinder with csv file
Date: 1 Apr 2017 03:17:22
Message: <58df5402$1@news.povray.org>
On 4/1/2017 6:47 AM, Jeff wrote:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> In the wee hours, I was thinking it would be nice to be able to generate a
>> Delaunay triangulation of data like this.
>
> Hi, i want to a question.
> 1. is it possible to use pictures as a plane ? so, i want to use the pictures as
> the layers, but because i have 4 mode in this file, i need 4 layers for it.
> so, each layer will have their own picture as the plane.
>
> example picture:
>
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTsQ_AU
> IBigB&biw=1536&bih=724
>
> i want to have 4 vertical layers and align to each other.
>
>
>
I use a very thin box instead of a plane and an image_map.

Or you can use a polygon. (From help file)


polygon {
   4,
   <0, 0>, <0, 1>, <1, 1>, <1, 0>
   texture {
     finish { ambient 1 diffuse 0 }
     pigment { image_map { gif "test.gif"  } }
     }
   //scale and rotate as needed here
   }


-- 

Regards
     Stephen


Post a reply to this message

From: clipka
Subject: Re: How to generate sphere and cylinder with csv file
Date: 1 Apr 2017 03:39:38
Message: <58df593a@news.povray.org>
Am 01.04.2017 um 09:17 schrieb Stephen:
> On 4/1/2017 6:47 AM, Jeff wrote:
>> "Bald Eagle" <cre### [at] netscapenet> wrote:
>>> In the wee hours, I was thinking it would be nice to be able to
>>> generate a
>>> Delaunay triangulation of data like this.
>>
>> Hi, i want to a question.
>> 1. is it possible to use pictures as a plane ? so, i want to use the
>> pictures as
>> the layers, but because i have 4 mode in this file, i need 4 layers
>> for it.
>> so, each layer will have their own picture as the plane.
>>
>> example picture:
>>
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTsQ_AU
>>
>> IBigB&biw=1536&bih=724
>>
>> i want to have 4 vertical layers and align to each other.
>>
>>
>>
> I use a very thin box instead of a plane and an image_map.
> 
> Or you can use a polygon. (From help file)

Or use a plane, and use the `once` flag on the image (preventing it from
repeating, and making the rest of the plane transparent) and `use_alpha
on` in the finish (preventing specular highlights from showing up in the
transparent portion).


Post a reply to this message

From: clipka
Subject: Re: How to generate sphere and cylinder with csv file
Date: 1 Apr 2017 03:47:47
Message: <58df5b23$1@news.povray.org>
Am 01.04.2017 um 08:01 schrieb Jeff:
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> In the wee hours, I was thinking it would be nice to be able to generate a
>> Delaunay triangulation of data like this.
> 
> another question is , is it possible to rotate, zoom in and zoom out freely in
> POV-RAY?
> 
> i mean, when you have thousands or even millions nodes and links and its so many
> of em, that you need to put your camera far far away, but then the nodes and
> links are sooooo small.
> 
> so, how to deliver the information effectively that people can see all of the
> nodes and links, but at the same time its not too small (or too hard) to see?
> is there any solutions to solve this problem in POV-RAY?

So you want to render not to a static image, but rather to /some/ output
file format that allows for free manipulation of the camera angle?


As for zooming in, that's easy: Just render a humongously large image.

As for rotating the camera around the scene, that's tricky. I think some
sites that let you see a product in 3D actually fake this feature by
technically showing a paused movie, and letting the user jog forward and
backward through the movie.


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 1 Apr 2017 15:25:00
Message: <web.58dffd74ae95604b80403a200@news.povray.org>
"Jeff" <jef### [at] gmailcom> wrote:

You just need to hit F1 and type in image_map.
or search around the web
http://www.joshuarenglish.com/cyclopedia/image_planar.html
http://www.f-lohmueller.de/pov_tut/tex/tex_870e.htm


> another question is , is it possible to rotate, zoom in and zoom out freely in
> POV-RAY?

Of course.  Read the docs on the camera {}
You can zoom in, out, rotate, pan, translate, change camera angle, and use all
sorts of different camera types other than the usual perspective camera.

> i mean, when you have thousands or even millions nodes and links and its so many
> of em, that you need to put your camera far far away, but then the nodes and
> links are sooooo small.

Yes, that's a problem with a whole field of study - presentation, analysis, and
visualization of multidimensional data.

> so, how to deliver the information effectively that people can see all of the
> nodes and links, but at the same time its not too small (or too hard) to see?
> is there any solutions to solve this problem in POV-RAY?

There's the size of the nodes, the thickness of the connecting lines, the
contrast between those and the background, etc.

> so, how did you do it in your experience that you have done it with millions of
> em?

Well, you have to determine what you want to show, and why.
Then you have to do the math to place the camera and adjust the view angle and
zoom.

I'd work on just getting the simple overlays to look good, as that will likely
take some time to get scaled and transparently overlaid properly.
Then see how all the data points look once they're all plotted on the map(s)


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 01:05:00
Message: <web.58e5cc16ae95604b653b97b10@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Jeff" <jef### [at] gmailcom> wrote:
>
> You just need to hit F1 and type in image_map.
> or search around the web
> http://www.joshuarenglish.com/cyclopedia/image_planar.html
> http://www.f-lohmueller.de/pov_tut/tex/tex_870e.htm
>
>
> > another question is , is it possible to rotate, zoom in and zoom out freely in
> > POV-RAY?
>
> Of course.  Read the docs on the camera {}
> You can zoom in, out, rotate, pan, translate, change camera angle, and use all
> sorts of different camera types other than the usual perspective camera.
>
> > i mean, when you have thousands or even millions nodes and links and its so many
> > of em, that you need to put your camera far far away, but then the nodes and
> > links are sooooo small.
>
> Yes, that's a problem with a whole field of study - presentation, analysis, and
> visualization of multidimensional data.
>
> > so, how to deliver the information effectively that people can see all of the
> > nodes and links, but at the same time its not too small (or too hard) to see?
> > is there any solutions to solve this problem in POV-RAY?
>
> There's the size of the nodes, the thickness of the connecting lines, the
> contrast between those and the background, etc.
>
> > so, how did you do it in your experience that you have done it with millions of
> > em?
>
> Well, you have to determine what you want to show, and why.
> Then you have to do the math to place the camera and adjust the view angle and
> zoom.
>
> I'd work on just getting the simple overlays to look good, as that will likely
> take some time to get scaled and transparently overlaid properly.
> Then see how all the data points look once they're all plotted on the map(s)


Hi, when i try to run the code it says "Parse Error: Expected'float,vector,or
string literal', string identifier found instead".

do you know what cause the problem?


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 02:15:01
Message: <web.58e5dcc7ae95604b653b97b10@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> So you want to render not to a static image, but rather to /some/ output
> file format that allows for free manipulation of the camera angle?
 movie, and letting the user jog forward and
> backward through the movie.

-- yes , i want to use my .png file , as the layer , and the nodes and the links
will be on the top of the layer(.png* file).
and i want the camera to rotate horizontal 360*, but i if i could rotate the
camera the way i want it after i render it would be better.


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 02:20:00
Message: <web.58e5dd82ae95604b653b97b10@news.povray.org>
Stephen <mca### [at] aolcom> wrote:
> On 4/1/2017 6:47 AM, Jeff wrote:
> > example picture:
> >
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTs
Q_AU

> I use a very thin box instead of a plane and an image_map.
>
> Or you can use a polygon. (From help file)
>
>
> polygon {
>    4,
>    <0, 0>, <0, 1>, <1, 1>, <1, 0>
>    texture {
>      finish { ambient 1 diffuse 0 }
>      pigment { image_map { gif "test.gif"  } }
>      }
>    //scale and rotate as needed here
>    }
>
>
> --
>
> Regards
>      Stephen

hi, thanks for answering. however, i want the picture to be normal square that
is adjustable in size. i try it to use the polygon , but i dont think its what i
want to do. i want 4 same pictures stack on the top of each other with a little
bit of distance. :)


Post a reply to this message

From: Stephen
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 03:05:11
Message: <58e5e8a7$1@news.povray.org>
On 4/6/2017 7:17 AM, Jeff wrote:
> Stephen <mca### [at] aolcom> wrote:
>> On 4/1/2017 6:47 AM, Jeff wrote:
>>> example picture:
>>>
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTs
> Q_AU
>
>> I use a very thin box instead of a plane and an image_map.
>>
>> Or you can use a polygon. (From help file)
>>
>>
>> polygon {
>>     4,
>>     <0, 0>, <0, 1>, <1, 1>, <1, 0>
>>     texture {
>>       finish { ambient 1 diffuse 0 }
>>       pigment { image_map { gif "test.gif"  } }
>>       }
>>     //scale and rotate as needed here
>>     }
>>
>>
>> --
>>
>> Regards
>>       Stephen
>
> hi, thanks for answering. however, i want the picture to be normal square that
> is adjustable in size. i try it to use the polygon ,

A box would have been better. Once you have the image in the box, the 
way you want it. Scale and translate the box. The image follows. :)

> but i dont think its what i
> want to do. i want 4 same pictures stack on the top of each other with a little
> bit of distance. :)
>

I would use four boxes for simplicity.
I can think of a couple of ways of making one object that has four 
images stacked.
Create a mesh and uv map the images in layers.
Create a density map with the images in layers and use media.

Four boxes in a union would be the simplest and easiest way to do it.


-- 

Regards
     Stephen


Post a reply to this message

From: clipka
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 04:19:36
Message: <58e5fa18$1@news.povray.org>
Am 06.04.2017 um 07:03 schrieb Jeff:

> Hi, when i try to run the code it says "Parse Error: Expected'float,vector,or
> string literal', string identifier found instead".
> 
> do you know what cause the problem?

My guess would be that you have arbitrary text in the CSV file; in that
case, you'll need to make sure it is enclosed in double quotes, e.g.

    "Foo"

instead of

    Foo


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 09:05:00
Message: <web.58e63ca1ae95604b80403a200@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:

> My guess would be that you have arbitrary text in the CSV file; in that
> case, you'll need to make sure it is enclosed in double quotes, e.g.
>
>     "Foo"
>
> instead of
>
>     Foo

Correct.
Jeff, look at the comment in the code:
//  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
//    etc.

That's exactly how it all will need to be formatted.
I'd probably use a spreadsheet, "copy" the data into an adjacent set of cells,
by using a formula that surrounds the relevant data with double quotes (the
String Literal POV-Ray is wanting for the #read directive) and commas and then
copying and pasting that into a text document, or displaying the data on a
separate spreadsheet and saving it to CSV format that way.

="\""&A1&"\", "&"\""&A2&"\", "&A3&"\", "&A4&"\", "&A5&"\","
or something like that

POV-Ray is a raytracer that generates 2D static images.  It can't render a 3D
model that you can then move around and inspect on-the-fly.
You can make an animation from a large series of static images sequentially
arranged, but it's as interactive as a VHS movie.

It seems like you have a fair amount of stuff you want to do - so for now, I'd
step back for a sec, write up some simple scenes from scratch, "wrap your head
around" POV-Ray's syntax, error messages, definitions, and other things peculiar
to it, and just get your 4 image layers working all by themselves.
You will have to use "transmit all 0.9" (or some other value) for the top 3
layers, so that you can see through them.


My standard bit of saved code for Image Mapping a box is:

#declare Feet = 12;
//  Sized image Map - 1 unit thick box
#declare XSize = 4*Feet;
#declare ImageMap = pigment {image_map {png "MyImage.png" once} };
#declare Resolution = max_extent (ImageMap);
#declare Resolution = Resolution + <0, 0, 1>;


#declare ImageMappedBox =
 box {0, 1
  texture {
   pigment {ImageMap}
  }
  translate <-0.5, -0.5, -0.5>
  scale Resolution*(1/Resolution.x)*XSize
  //translate y*(Resolution.y / Resolution.x)*XSize/2
 }

object {ImageMappedBox translate <0, 0, 0>}

Set yourself up some visible axes, and maybe a grid to give yourself some
orientation in the scene and maybe a sphere at the origin for a reference
marker.  (AT the beginning, it's easy to forget to include a camera, a light
source, get you axes mixed up, use right-hand rule instead of left hand rule,
etc)

You're going to need all these skills once you start creating a scene that's set
up for rendering frames for an animation - because you're going to need to
understand how the guts of the code works when you write the formulas with the
clock variable to control how everything is rendered in each successive frame.

Do everything stepwise, and save a working result with a different filename, so
that as you progressive, you don't overwrite your Last-Known-Good scene.

1. make a basic scene with axes
2. add a grid to give a sense of scale
3. add 4 layered boxes
4. move you camera around by editing the code and rerendering
4a. save as a different filename
5. add image_map textures
6. adjust transmit and scaling
..
..
..
N. add point and lines from the first scene code
..
..
..
N++. define the formulas to create a series of renders for animating
N++1.  Run you .ini animation file and let it churn them all out
N++2. Use a 3rd party software (VideoMach, etc) to make the static images into a
video file

and then tweak, tweak, tweak, rewrite and debug   ;)

There are plenty of example scenes, Lohmueller's site, the standard include
drop-down menu, and the POV-Ray scene files sections of the forum.

Only you will know exactly what you want, and we can't write it all for you -
you're best served by spending a few hours ( ;) ) grappling with what we all
struggled with when we first started doing this.

But we are here to help  :)


Post a reply to this message

From: Alain
Subject: Re: How to generate sphere and cylinder with csv file
Date: 6 Apr 2017 11:33:44
Message: <58e65fd8@news.povray.org>
Le 17-04-06 à 02:17, Jeff a écrit :
> Stephen <mca### [at] aolcom> wrote:
>> On 4/1/2017 6:47 AM, Jeff wrote:
>>> example picture:
>>>
https://www.google.com/search?q=multi-layer+networks&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiu9YLwxoLTAhUOwGMKHdU9CTs
> Q_AU
>
>> I use a very thin box instead of a plane and an image_map.
>>
>> Or you can use a polygon. (From help file)
>>
>>
>> polygon {
>>    4,
>>    <0, 0>, <0, 1>, <1, 1>, <1, 0>
>>    texture {
>>      finish { ambient 1 diffuse 0 }
>>      pigment { image_map { gif "test.gif"  } }
>>      }
>>    //scale and rotate as needed here
>>    }
>>
>>
>> --
>>
>> Regards
>>      Stephen
>
> hi, thanks for answering. however, i want the picture to be normal square that
> is adjustable in size. i try it to use the polygon , but i dont think its what i
> want to do. i want 4 same pictures stack on the top of each other with a little
> bit of distance. :)
>


#declare Base_poly = polygon{5, <0,0>,<0,1>,<1,1>,<1,0>,<0,0>}
// a featureless 4 sided polygon

union{
#declare V_Pos = 0;
#while(V_Pos<4)
  object{ Base_poly translate 0.1*z}
  #declare Z_Pos = Z_Pos + 1;
#end
  texture{image_map{gif"test.gif"}} finish{emission 1 diffuse 0}}
// apply the texture to all polys at once
  scale Your_Scale
  rotate Rotation
  translate Somewhere
}


Post a reply to this message

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 7 Apr 2017 13:00:01
Message: <web.58e7c48bae95604bb8de811f0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> clipka <ano### [at] anonymousorg> wrote:
>
> > My guess would be that you have arbitrary text in the CSV file; in that
> > case, you'll need to make sure it is enclosed in double quotes, e.g.
> >
> >     "Foo"
> >
> > instead of
> >
> >     Foo
>
> Correct.
> Jeff, look at the comment in the code:
> //  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
> //    etc.
>
> That's exactly how it all will need to be formatted.
> I'd probably use a spreadsheet, "copy" the data into an adjacent set of cells,
> by using a formula that surrounds the relevant data with double quotes (the
> String Literal POV-Ray is wanting for the #read directive) and commas and then
> copying and pasting that into a text document, or displaying the data on a
> separate spreadsheet and saving it to CSV format that way.
>
> ="\""&A1&"\", "&"\""&A2&"\", "&A3&"\", "&A4&"\", "&A5&"\","
> or something like that
>
> POV-Ray is a raytracer that generates 2D static images.  It can't render a 3D
> model that you can then move around and inspect on-the-fly.
> You can make an animation from a large series of static images sequentially
> arranged, but it's as interactive as a VHS movie.
>
> It seems like you have a fair amount of stuff you want to do - so for now, I'd
> step back for a sec, write up some simple scenes from scratch, "wrap your head
> around" POV-Ray's syntax, error messages, definitions, and other things peculiar
> to it, and just get your 4 image layers working all by themselves.
> You will have to use "transmit all 0.9" (or some other value) for the top 3
> layers, so that you can see through them.
>
>
> My standard bit of saved code for Image Mapping a box is:
>
> #declare Feet = 12;
> //  Sized image Map - 1 unit thick box
> #declare XSize = 4*Feet;
> #declare ImageMap = pigment {image_map {png "MyImage.png" once} };
> #declare Resolution = max_extent (ImageMap);
> #declare Resolution = Resolution + <0, 0, 1>;
>
>
> #declare ImageMappedBox =
>  box {0, 1
>   texture {
>    pigment {ImageMap}
>   }
>   translate <-0.5, -0.5, -0.5>
>   scale Resolution*(1/Resolution.x)*XSize
>   //translate y*(Resolution.y / Resolution.x)*XSize/2
>  }
>
> object {ImageMappedBox translate <0, 0, 0>}
>
> Set yourself up some visible axes, and maybe a grid to give yourself some
> orientation in the scene and maybe a sphere at the origin for a reference
> marker.  (AT the beginning, it's easy to forget to include a camera, a light
> source, get you axes mixed up, use right-hand rule instead of left hand rule,
> etc)
>
> You're going to need all these skills once you start creating a scene that's set
> up for rendering frames for an animation - because you're going to need to
> understand how the guts of the code works when you write the formulas with the
> clock variable to control how everything is rendered in each successive frame.
>
> Do everything stepwise, and save a working result with a different filename, so
> that as you progressive, you don't overwrite your Last-Known-Good scene.
>
> 1. make a basic scene with axes
> 2. add a grid to give a sense of scale
> 3. add 4 layered boxes
> 4. move you camera around by editing the code and rerendering
> 4a. save as a different filename
> 5. add image_map textures
> 6. adjust transmit and scaling
> ..
> ..
> ..
> N. add point and lines from the first scene code
> ..
> ..
> ..
> N++. define the formulas to create a series of renders for animating
> N++1.  Run you .ini animation file and let it churn them all out
> N++2. Use a 3rd party software (VideoMach, etc) to make the static images into a
> video file
>
> and then tweak, tweak, tweak, rewrite and debug   ;)
>
> There are plenty of example scenes, Lohmueller's site, the standard include
> drop-down menu, and the POV-Ray scene files sections of the forum.
>
> Only you will know exactly what you want, and we can't write it all for you -
> you're best served by spending a few hours ( ;) ) grappling with what we all
> struggled with when we first started doing this.
>
> But we are here to help  :)


hi, thank you so much. here is my code now. so, i have for layers , and a red
sphere.

#include "colors.inc"

camera {
       location <55,30,90>
       look_at <55,0,126>
       rotate <0,clock*360,0>
       }

light_source  {
              <55,30,75>
              color White
              }

global_settings {
 assumed_gamma 0.1
 #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
 ambient_light rgb <1, 1, 1> // <======== flat, even illumination
}

#declare EarthRadius = 6367*0.621371; //radius in m

#declare Feet = 12;
//  Sized image Map - 1 unit thick box
#declare XSize = 4*Feet;
#declare ImageMap = pigment {image_map {png "beijing.png" once} };
#declare Resolution = max_extent (ImageMap);
#declare Resolution = Resolution + <0, 0, 1>;
---------------------------------------------------------------------------
>>#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""

#macro C2S (Cartesian)

 #local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
2));
 #local Lat = degrees (asin (Cartesian.z / R));
 #local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
 #local LatLon = <Lat, Lon>;
 LatLon;
#end // end macro C2S

"" HERE TOO ? ""
------------------------------------------------------------------------
#declare ImageMappedBox =
 box {0, 1
  texture {
   pigment {ImageMap}
  }
  translate <0, 0, 0>
  scale Resolution*(1/Resolution.x)*XSize
  rotate <90,0,0>
  //translate y*(Resolution.y / Resolution.x)*XSize/2
 }

object {ImageMappedBox translate <30,0,110>}
object {ImageMappedBox translate <30,5,110>}
object {ImageMappedBox translate <30,10,110>}
object {ImageMappedBox translate <30,15,110>}

sphere {
        <55,15,110>, 2
        pigment {Red}
}
--------------------------------------------------------
>>//  data format: "bus", "CN/Beijing", "bus2382659521", 116.4093833, 39.9067192,
//    etc.
#declare Type = "";
#declare Location = "";
#declare ID = "";
#declare Latitude = 0;
#declare Longitude = 0;

""and this part, do i have to do it just one of 'em? or what? , i would like to
change it like this (below) ""

#declare Mode = "";
#declare City = "";
#declare ID = "";
#declare Latitude = 0;
#declare Longitude = 0;
------------------------------------------------
>>// count locations for sizing array
#declare Locations = 0;------> " what does this line do ? "
#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
---------------------------------------------------
>>#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 ""
-----------------------------------------------------------------


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
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

From: Jeff
Subject: Re: How to generate sphere and cylinder with csv file
Date: 8 Apr 2017 09:55:00
Message: <web.58e8eb3bae95604b4de507a60@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> "Jeff" <jef### [at] gmailcom> wrote:

here is my code now:

global_settings {
 assumed_gamma 1.0
 #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
 ambient_light rgb <1, 1, 1> // <======== flat, even illumination
}

#include "colors.inc"

camera {
 location <55,25,80>
 right    x*image_width/image_height
 look_at <55,0,126>
}

light_source{ <10,10,-10>  color rgb <1, 1, 1>}

#declare Feet = 12;
//  Sized image Map - 1 unit thick box
#declare XSize = 4*Feet;
#declare ImageMap = pigment {image_map {png "beijing.png" once} };
#declare Resolution = max_extent (ImageMap);
#declare Resolution = Resolution + <0, 0, 1>;

#declare ImageMappedBox =
 box {0, 1
  texture {
   pigment {ImageMap}
  }
  translate <0, 0, 0>
  scale Resolution*(1/Resolution.x)*XSize
  rotate <90,0,0>
  //translate y*(Resolution.y / Resolution.x)*XSize/2
 }
object {ImageMappedBox translate <31,0,115>}
object {ImageMappedBox translate <31,5,115>}
object {ImageMappedBox translate <31,10,115>}
object {ImageMappedBox translate <31,15,115>}

----------------what does the code blocks below
do?---------------------------#declare EarthRadius = 6367; //radius in km
#declare EarthRadius = 6367*0.621371; //radius in mi

#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, Y, Z>;
 Cartesian;
#end // end macro S2C

#macro C2S (Cartesian)

 #local R = sqrt(pow(Cartesian.x, 2) * pow(Cartesian.y, 2) * pow(Cartesian.z,
2));
 #local Lat = degrees (asin (Cartesian.z / R));
 #local Lon = degrees (atan2 (Cartesian.y, Cartesian.x));
 #local LatLon = <Lat, Lon>;
 LatLon;
#end // end macro C2S
------------------------------------------------------------------
//  data format: "bus", "CN/Beijing", "bus2382659521", 39.9067192, 116.4093833,
//    etc.
#declare Mode = "bus";
#declare City = "CN/Beijing";
#declare ID = "bus23822659521";
#declare Latitude = 39.9067192;
#declare Longitude = 116.4093833;

--------------------------------------------------------------
#declare modez = 'bus' = 0; 'subway' = 5; 'rail' = 10; 'tram = 15
here i try to declare different z position for different mode, so they are not
in the same height(layer of picture)
---------------------------------------------------------------
// count locations for sizing array
#declare Locations = 0;
#fopen nodes "nodes.csv" read
#while (defined (nodes))
 #read (nodes, mode, city, ID, Latitude, Longitude)
 #declare Locations = Locations + 1;
#end
#fclose nodes

#declare _mode = bus[Locations];
#declare _city = CN/Beijing[Locations];
#declare _ID = bus2382659521[Locations];
#declare _Latitude = 39.9067192[Locations];
#declare _Longitude = 116.4093833[Locations];
#declare _XYZ = Longitude[Locations];Latitude[Locations];modesz[Locations]

// input data into array
#declare Datapoint = 0;
#fopen links "links.csv" read
#while (defined (links))
 #read (links, Mode, Source, Target, Length)

 #declare _Mode [Datapoint] = Mode;
 #declare _Source [Datapoint] = Source;
 #declare _Target [Datapoint] = Target;
 #declare _Length [Datapoint] = Length;
 #declare _XYZ [Datapoint] = S2C (<_Longitude[Datapoint],
_Latitude[Datapoint,_XYZ[Datapoint]>);
 #declare Datapoint = Datapoint + 1;
#end
#fclose links

#declare Marker = 0.25;
#declare Line = 0.05;
#declare Linecolor = pigment {Magenta};

#for (Point, 0, Locations-1)

 #if (Mode = "bus")
  #declare Color = pigment {Red};
 #elseif (Mode = "subway")
  #declare Color = pigment {Green};
 #elseif (Mode = "rail")
  #declare Color = pigment {Blue};
 #elseif (Mode = "tram")
  #declare Color = pigment {Yellow};
 #else
  #debug "Unidentified Location Type.  \n"
  #declare Color = pigment {White};
 #end

 #declare S = 1; //<0.1, 0.1, 1/4000>;
 #declare T = <1350, 1130, -3500>;

 sphere {0.3, Marker pigment {Color} translate _XYZ[Point]*S translate T}

 #if (Point > 0)
  cylinder {LastPoint*S, _XYZ[Point]*S, Line pigment {Linecolor} translate T}
 #end // end if

 #debug concat( "Vector = ", vstr(3, _XYZ[Point]*S, ", ", 3, 0), " \n")

 #declare LastPoint = _XYZ[Point];

#end // end for Point


Post a reply to this message

From: Alain
Subject: Re: How to generate sphere and cylinder with csv file
Date: 9 Apr 2017 22:31:53
Message: <58eaee99$1@news.povray.org>
Le 17-04-08 à 09:52, Jeff a écrit :
> "Bald Eagle" <cre### [at] netscapenet> wrote:
>> "Jeff" <jef### [at] gmailcom> wrote:
>
> here is my code now:
>
> global_settings {
>  assumed_gamma 1.0
>  #default {texture {pigment {rgb <1, 1, 1>} finish {ambient 1}}}
>  ambient_light rgb <1, 1, 1> // <======== flat, even illumination

WRONG !
ambient_light is multiplied with the ambient component of the finish. 
rgb<1,1,1> is the DEFAULT value.
So, that line is really a «no operation».
By the way, it's bad practice to place the #default statement into the 
global_settings block. It have nothing to do in that location. Place it 
after.

global_settings{ assumed_gamma 1}
#default{ texture{ pigment{ rgb 1 } finish{ ambient 1 }}}


> }
>
> #include "colors.inc"
>
> camera {
>  location <55,25,80>
>  right    x*image_width/image_height
>  look_at <55,0,126>
> }
>
> light_source{ <10,10,-10>  color rgb <1, 1, 1>}
>
> #declare Feet = 12;
> //  Sized image Map - 1 unit thick box
> #declare XSize = 4*Feet;
> #declare ImageMap = pigment {image_map {png "beijing.png" once} };
> #declare Resolution = max_extent (ImageMap);
> #declare Resolution = Resolution + <0, 0, 1>;
>
> #declare ImageMappedBox =
>  box {0, 1
>   texture {
>    pigment {ImageMap}
>   }
>   translate <0, 0, 0>
>   scale Resolution*(1/Resolution.x)*XSize
>   rotate <90,0,0>
>   //translate y*(Resolution.y / Resolution.x)*XSize/2
>  }
> object {ImageMappedBox translate <31,0,115>}
> object {ImageMappedBox translate <31,5,115>}
> object {ImageMappedBox translate <31,10,115>}
> object {ImageMappedBox translate <31,15,115>}
>
> ----------------what does the code blocks below
> do?---------------------------#declare EarthRadius = 6367; //radius in km
> #declare EarthRadius = 6367*0.621371; //radius in mi

Nothing at all as those variables are never used.
In some other cases, those are usefull for some reason, like actually 
following Earth's curvature.


Post a reply to this message

From: Bald Eagle
Subject: Re: How to generate sphere and cylinder with csv file
Date: 10 Apr 2017 08:05:00
Message: <web.58eb73dcae95604bc437ac910@news.povray.org>
Alain <kua### [at] videotronca> wrote:

> > ----------------what does the code blocks below
> > do?---------------------------#declare EarthRadius = 6367; //radius in km
> > #declare EarthRadius = 6367*0.621371; //radius in mi
>
> Nothing at all as those variables are never used.
> In some other cases, those are usefull for some reason, like actually
> following Earth's curvature.

You were too hasty, my friend.
EarthRadius is used in the S2C macro as the multiplier for the trig functions.

S2C converts Sperical coordinates (lat, long) to Cartesian (x, y, z) and
C2S obviously does the reverse.
I just coded up both for completeness.


If you use layered textures with an alpha channel, you don't need to code up
separate boxes for your maps.   You can just sequentially apply each texture to
the box, with the last texture defined being "on top" - just like applying
successive layers of paint.

See the docs or Lohmueller's site, or maybe the standard insert menu.


Post a reply to this message

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