3
3
require 'propane'
4
4
require 'arcball'
5
5
require 'csv'
6
- # Capital name, Latitude and Longitude from csv
7
-
6
+ # To store Capital name, Latitude and Longitude from csv
8
7
Place = Struct . new ( :lat , :lon , :name )
9
8
10
-
9
+ # Sketch class
11
10
class LatLong < Propane ::App
12
11
load_library :vector_utils
13
12
# Uses to_cartesian to map lat lon of cities, read from a csv file, on a globe
14
13
attr_reader :places
15
14
def setup
16
15
sketch_title 'Latitude and Longitude'
17
- noStroke
18
- textSize ( 9 )
16
+ smooth ( 8 )
17
+ no_stroke
18
+ text_size ( 9 )
19
19
Processing ::ArcBall . init self
20
20
@places = [ ]
21
21
CSV . foreach ( data_path ( 'capitals.csv' ) , headers : true ) do |row |
@@ -31,15 +31,15 @@ def draw
31
31
lights
32
32
counter = 0
33
33
places . each do |place |
34
- p = VectorUtil . to_cartesian ( lat : place . lat , long : place . lon , radius : 300 )
34
+ pos = VectorUtil . to_cartesian ( lat : place . lat , long : place . lon , radius : 300 )
35
35
push_matrix
36
- translate ( p . x , p . y , p . z )
37
- polar = VectorUtil . cartesian_to_polar ( vec : p )
36
+ translate ( pos . x , pos . y , pos . z )
37
+ polar = VectorUtil . cartesian_to_polar ( vec : pos )
38
38
rotate_y ( polar . y )
39
39
rotate_z ( polar . z )
40
40
push_matrix
41
41
fill ( 255 )
42
- text ( place . name , 0 , 0 ) if ( counter % 3 ) . zero?
42
+ text ( place . name , 0 , 0 ) if ( counter % 3 ) . zero?
43
43
pop_matrix
44
44
fill ( 255 , 255 , 0 , 100 )
45
45
box ( 8 , 3 , 3 )
0 commit comments