quaternionLatLongExample
About QuaternionLatLong Example
--

Learning Objectives
This openFrameworks example utilizes quaternions to plot latitude and longitude onto a sphere.
In the code, pay attention to:
citieswhich is a Vector to holdCityobjects for the data to plot onto the sphereofTranslate(ofGetWidth()/2, ofGetHeight()/2, 40);to make 0,0 the center of the screenofRotate(ofGetFrameNum(), 0, 1, 0);to spin at the rate of 1 degree per frameofDrawSphereto draw the spherelatRot.makeRotate(cities[i].latitude, 1, 0, 0);to create a quaternion which will perform a rotation of an anglelongRot.makeRotate(cities[i].longitude, 0, 1, 0);to create a quaternion which will perform a rotation of an anglespinQuat.makeRotate(ofGetFrameNum(), 0, 1, 0);to create another quaternion to ensure it spins on the y axisglm::vec3 worldPoint = latRot * longRot * spinQuat * center;to generate the point to map the city by multiplying all of the quaternions and then multipying the center vector to apply the rotation to the center vector
Expected Behavior
When launching this app, you should see
- A white mesh sphere centered in the middle of the screen with a black background
- The sphere will have the cities latitude and longitude mapped and labeled on the sphere
- The sphere will be constantly rotating