33require 'propane'
44require 'arcball'
55require 'csv'
6- # Capital name, Latitude and Longitude from csv
7-
6+ # To store Capital name, Latitude and Longitude from csv
87Place = Struct . new ( :lat , :lon , :name )
98
10-
9+ # Sketch class
1110class LatLong < Propane ::App
1211 load_library :vector_utils
1312 # Uses to_cartesian to map lat lon of cities, read from a csv file, on a globe
1413 attr_reader :places
1514 def setup
1615 sketch_title 'Latitude and Longitude'
17- noStroke
18- textSize ( 9 )
16+ smooth ( 8 )
17+ no_stroke
18+ text_size ( 9 )
1919 Processing ::ArcBall . init self
2020 @places = [ ]
2121 CSV . foreach ( data_path ( 'capitals.csv' ) , headers : true ) do |row |
@@ -31,15 +31,15 @@ def draw
3131 lights
3232 counter = 0
3333 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 )
3535 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 )
3838 rotate_y ( polar . y )
3939 rotate_z ( polar . z )
4040 push_matrix
4141 fill ( 255 )
42- text ( place . name , 0 , 0 ) if ( counter % 3 ) . zero?
42+ text ( place . name , 0 , 0 ) if ( counter % 3 ) . zero?
4343 pop_matrix
4444 fill ( 255 , 255 , 0 , 100 )
4545 box ( 8 , 3 , 3 )
0 commit comments