Cesium's height value is altitude? or, above sea level? - gis

What is the Cesium(https://cesiumjs.org/)'s height value meaning?
Altitude value from Ellipsoid? Or, above sea level?
Note: difference of altitude and above sea level is, [altitude] = [above sea level] + [Geoid value]
What I want to do is set Cesium's camera to same position of real GPS value get from Smartphone's GPS, but GPS's height value is altitude, so if Cesium use above sea level as it's height reference, Camera's position is set to too much high position...
Anyone know this?

I found the answer by myself:
https://cesiumjs.org/Cesium/Build/Documentation/Cartographic.html
"The height, in meters, above the ellipsoid."

Related

Determine the position between the two positions on the map in android studio

We have two position A and B with the specified characteristics on the map.
We want to position out between these two points at a distance of 50 meters.
enter image description here
You can use the geometry library for this:
https://developers.google.com/maps/documentation/javascript/geometry
https://developers.google.com/maps/documentation/javascript/reference/3/#spherical
From the docs:
Navigation Functions
When navigating on a sphere, a heading is the angle of a direction from a fixed reference point, usually true north. Within the Google Maps API, a heading is defined in degrees from true north, where headings are measured clockwise from true north (0 degrees). You may compute this heading between two locations with the computeHeading() method, passing it two from and to LatLng objects.
Given a particular heading, an origin location, and the distance to travel (in meters), you can calculate the destination coordinates using computeOffset().
In your case you might want to get the heading first
var heading = google.maps.geometry.spherical.computeHeading(latLngFrom, latLngTo)
then you can get the offset location:
google.maps.geometry.spherical.computeOffset(latlngFrom, distance, heading)

Change in rotation of a tank-like vehicle [duplicate]

This question already has answers here:
Formula for controlling the movement of a tank-like vehicle?
(10 answers)
Closed 7 years ago.
I'm trying to simulate a tank-like/skid-steered vehicle, i.e. both of the wheels (one on each side) have separate velocities, and steering is done by increasing or decreasing the velocity of one of the sides.
For example, If I set the velocity of the left wheel to 5, and the right wheel to 3, it will turn right. What I'd like to know is, given the velocities of the wheels Vl and Vr, and the distance between the wheels D, by how many degrees will the direction the vehicle is pointing in change in one tick?
I've tried looking at Formula for controlling the movement of a tank-like vehicle?, and the links on that question, but haven't come up with anything. All my best guesses have failed.
First: the really easy edge cases. if V_l and V_r are zero, don't move. If they're the same, don't turn.
Second, if only one of V_l and V_r are zero, the tank pivots around the stationary tread, and the moving tread traces out an arc of length V_big with a radius of curvature D. theta = Vbig/D, plus or minus some sign conventions based on your coordinates. (the tank base also translates some distance but the calculations for that are dependent on where the center of rotation of the tank is defined to be and your coordinate system, so that detail is left as an exercise for the reader.)
Third, symmetry concerns! Obviously tank treads turning is left/right symmetric. If the left tread is twice as fast as the right the tank should turn the same amount as if the right tread is twice as fast as the left, just in a different direction. Ditto for going backwards.
Fourth: Meat and potatoes! I'm assuming neither tank tread can slip whatsoever. The faster tread traces an arc of length V_fast on a circle of radius r+D marked out by an angle theta. If you recall your trig V_fast=(r+D)*theta. The slower wheel traces out an arc of length V_slow on a circle of radius r marked out by the same angle.(V_slow = theta*r) Divide one equation by the other, receive V_fast/V_slow = (r+D)/r. Apply algebra to provide r=D/((V_fast/V_slow)-1) Note that this explodes appropriately when V_slow is zero or when V_fast=V_slow, and you appropriately receive r=D when V_fast=2*V_slow Recall that theta=V_slow*r: theta=(V_fast-V_slow)/D
IN RADIANS, mind you That's a crucial detail.
NOTE: If you define 'turning right' as positive theta and turning left as negative theta, it all works out and theta=(V_l-V_r)/D, even for negative speeds. The tank won't turn around to face the direction of travel, it'll keep facing the correct way.

HTML5 overlapping of shapes with global composite operation

I want to do this animation - Water level rises in sea engulfing a small mountain having pits. When water recedes some of it stays in the pockets and again when water level rises it all becomes one. This animation continues indefinitely. Now i have tried doing this by using two approaches,
1) Drawing and clearing the water in pool with the flow of water in sea.
ctx.bezierCurveTo(x1,y1,x2,y2,end_x,end_y);
I changed first and second control points with the flow of water to make the base change from little flat to spherical and vice-versa. But wasn't smooth and also second pit has irregular base so impossible.
2) I made the required pockets filled with water and played with opacity so that pocket water mixes with sea water when submerged. Again this approach doesn't give smooth look.
Here's what it should look like:
The base image is background of canvas, i just have to control water flow.
Please suggest what to do.
You can use compositing to have your sea water seamlessly intrude on your mountain
In particular "source-out" compositing allows you to draw new content only where it doesn't overlap any existing content.
Therefore "source-out" compositing will allow you to draw new sea-water only where it doesn't overlap the existing mountain.
When the water is rising:
clear canvas
set globalCompositeOperation="source-over" // the default, new drawings will overdraw
draw your mountain
set globalCompositeOperation="source-out" // new sea water will not overdraw existing mountains
draw the rising sea water
increase the height of the sea water
repeat with #1 until your sea water is at desired height
When the water is falling:
clear canvas
set globalCompositeOperation="source-over" // the default, new drawings will overdraw
draw your mountain
set globalCompositeOperation="source-out" // new sea water will not overdraw existing mountains
draw the retained sea water only in the pit of your mountain
draw the falling sea water
decrease the height of the sea water
repeat with #1 until your sea water is at desired height
After much thinking found a 2-step approach.
Step-1 >>
1) Draw water in sea (Destination)
2) Set ctx.globalCompositeOperation="destination-out";
3) Draw pool water (Source)
This will remove part of source overlapping with dest. thus creating sea water with a hollow space(transparency) in place of pool. Now this image with the hole becomes the dest. image on which i have to draw only pool water so that the consistency of water is maintained.
Step-2 >>
1) Set ctx.globalCompositeOperation="destination-atop";
2) Draw pool water (Source)
This will draw dest. only where dest. and source overlap i.e. when dest. image with hole(transparency in place of pool) and pool overlap sea water is created in hollow area. Point to be noted - pool water is like a subset of sea water so i don't have to worry about pool water(Source) to be created as it is with "destination-atop".

Given a lat/lng coordinate, calculate the min and max lat/lng values for a 10 km area

Lets say I have a lat lng coordinate and I want to place that at the center of a square that is 10km wide and then get the minimum lat/lng and maximum lat/lng.
Is there an easy way to do this that already exists?
If it doesn't need to be exact, it is pretty easy:
For the latitude, 1 km is 0.009 degrees (follows from the original definition of meter). Since your square is 5 km around the center, you just need to add and subtract 0.045 degrees from the center point.
For the longitude, it is slightly more complicated: Divide the above value with the cosine of the latitude.
In code:
lat_min = lat_center - 0.045;
lat_max = lat_center + 0.045;
long_min = long_center - (0.045 / Math.cos(lat_center*Math.PI/180);
long_max = long_center + (0.045 / Math.cos(lat_center*Math.PI/180);
(Math.PI/180 is needed to convert from degrees to radians).
Beware: Does not work around the poles.
How is the square oriented? Parallel to the equator? If so, then just do a bearing of 45 deg, 5km * sqrt(2) distance from your lat/lon to get the upper right corner. Similar for the bottom left, use a bearing of 225 deg.
See Destination point given distance and bearing from start point at http://www.movable-type.co.uk/scripts/latlong.html

Google Maps pixel height by latitude

In Google maps, the closer one gets to the pole, the more strechted out the map gets and sp each pixel of map represents less movment (asymtotically to 0 at the north pole)
I'm looking for a formula to connect the width of a pixel in degrees to the latitute (i.e. the real world distance represented by a pixel on the map). I have some data points here for zoom level 12 (IIRC)
Lat Width
0 0.703107352
4.214943141 0.701522096
11.86735091 0.688949038
21.28937436 0.656590105
30.14512718 0.60989762
35.46066995 0.574739011
39.90973623 0.541457085
41.5085773 0.528679228
44.08758503 0.507194173
47.04018214 0.481321842
48.45835188 0.468430215
51.17934298 0.442887842
63.23362741 0.318394373
72.81607372 0.208953319
80.05804956 0.122131316
90 0
The reason for doing this is I want to input lat/lng pairs and sort out exactly what pixel they would be located with respect to 0,0
I might be wrong but are you sure thos points are the pixel height? They seem to be a cosine which would be the pixel width not the height.
After a little trigonometry the pixel height adjusts to the formula:
where R is the earth radius, phi is the latitude and h is the height of a pixel in the equator.
This formula does not adjust to your points, that's why I asked if it was the width instead.
Anyway if you want so much precision that you cannot use the approximation in the previous answer you should also consider the R variable with the latitude and even with that I don't think you'll get the exact result.
Update:
Then the formula would be a cosine. If you want to take the variable radius of the earth the formula would be:
where R is the radius of the earth and d(0) is your pixel width at the equator. You may use this formula for R assuming the eearth to be an ellipsoid:
with a = 6378.1 (equator) and b = 6356.8 (poles)
While I am not sure what "height of a pixel" means, the plot of data (shown below) seems to fit the equation
y = a + bx + cx^2 + dx^3 where y = height, x = latitude
with coefficients
a = 7.0240278979641990E-01
b = 3.7784208874521786E-04
c = -1.2602864112736206E-04
d = 3.8304225582846095E-07
The general approach to find the equation is to first plot the data, then hypothesize the type of function, and then do a regression to find the coefficients.