I am trying to compute area of a latitude-longitude rectangle using following formula:
A = (pi/180)R^2 |sin(lat1)-sin(lat2)| |lon1-lon2|
R is earth radius (6378 kms)
(source: http://mathfax.com/area-of-a-latitude-longitude-rectangle/)
Derivation of the formula at above url seems correct.
But using this formula to compute area for small/medium cities gives a much larger result.
For example: Bounding box of Mountain View, CA
(Source: maps.googleapis.com/maps/api/geocode/json?address=mountain%20view,%20california&sensor=false)
is (37.3565410, -122.1178620) - (37.4698870, -122.0446720)
Plugging these values in the formula shows an area of 5647 sq.km, that is too large.
Actual area is 32 sq.km. Bounding box area should not be too far off.
What is wrong with this calculation?
You have to convert the latitudes and longitudes into radians before calling sin.
Related
I'm trying to calculate position with accelerometer and gyroscope data I get from the phone. In this calculation I am using quaternations for attitude update but the calculated point coordinates are going left rather than right. So actually, if I take the symmetric right side, I will get the correct values.
Calculation results:
Arrow shows the North direction. The actual route to go is shown in red.
The formula I used is as follows:
T_s = sampling period
w = refers to gyro values.
q_k = updated attitude
The yaw angle, which should be referenced for the left deflection, is 355 degrees, but as I mentioned before, it turns to the right with this angle. I couldn't figure out where the problem came from, can you help?
I have a 2d grid where pixel centers are at the intersection of two half-grid lines, as shown below.
I also have a shape that is drawn on this grid. In my case the shape is a glyph, and is described by segments. Each segment has a start point, end point and a number of off-curve points. These segments can be quadratic curves or lines. What's important is that I can know the points and functions that make up the outline of the shape.
The rule for deciding which pixels should be turned on is simple: if the center of the pixel falls within the shape outline, turn that pixel on. The following image shows an example of applying this rule.
Now the problem I'm facing has to do with anti aliasing. What I'd like to do is to calculate what percentage of the area of a given pixel falls within the outline. As an example, in the image above, I've drawn a red square around a pixel that would be about 15% inside the shape.
The purpose of this would be so that I can then turn that pixel on only by 15% and thus get some cleaner edges for the final raster image.
While I was able to find algorithms for determining if a given point falls within a polygon (ray casting), I wasn't able to find anything about this type of problem.
Can someone can point me toward some algorithms to achieve this? Also let me know if I'm going about this problem in the wrong way!
This sounds like an X, Y problem.
You are asking for a way to calculate the perecentage of pixel coverage, but based on your question, it sounds that what you want to do is anti alias a polygon.
If you are working only with single color 2D shapes (i.e red, blue, magenta... squares, lines, curves...) A very simple solution is to create your image and blur the result afterwards.
This will automatically give you a smooth outline and is simple to implement in many languages.
There are 5 objects in a row which i want to distribute in a line
but i want 15 pixels distance between edges of objects in photoshop
what I am getting is Distribution Object by center, but not same distance between objects, How can i get it?
Here's what i want (case 2) & what i get (case 1).
Thanks in Advance!!!!
What you want to do is zoom in to the pictures to the point of where you can literally count each pixel. And start adjusting each picture with the arrow keys.
Or draw a square that measures 15 pixels wide and duplicate it. Once you are done with adjustment you can delete the square.
I'm trying to calculate bounds for square with particular radius and when center of square is known(longitude, latitude). But I'm getting into troubles with it.
I've tried to use haversine formula from here :
But I'm getting into troubles when radius is pretty big.
Currently to find
1). latitude delta in radians I use:
radiusInMeters / EARTH_RADIUS_METERS
2). longitude delta in radians I use:
2.0 * | arcsin( |sin(radiusInMeters/(EARTH_RADIUS_METERS*2.0))
/ |cos(latitudeStart)| | ) |
These formulas I got from haversine formula.
Could please someone point me to the exact generic formula for calculations which will be good for big and small distances for my case.
Also how should be handled situations when radius exceeds -180˚/180˚ on longitude or -90˚/90˚ on latitude?
UPDATE
Some clarifications. Let's say that I'm staying in some particular point with coordinates (lon, lat), where lon is -113˚ and lat 50˚.
I would like to query points in some radius of interest from database. For that I need to calculate bounds of a "square". (Then filter-out stuff that's not in interesting radius). Formula above works fine on small distances(let's say 'till 100 kilometers(63 miles). But the more I go from equatorial point the poles, the more rounding errors I get.)
Thanks in advance
Given this grid ( http://i.stack.imgur.com/Nz39I.jpg is a trapezium/trapezoid, not a square), how do you find the point clicked by the user? I.e. When the user clicks a point in the grid, it should return the coordinates like A1 or D5.
I am trying to write pseudo code for this and I am stuck. Can anyone help me? Thanks!
EDIT: I am still stuck... Does anyone know of any way to find the height of the grid?
If it is a true perspective projection, you can run the click-point through the inverse projection to find it's X,Z coordinates in the 3D world. That grid has regular spacing and you can use simple math to get the A1,D5,etc.
If it's just something you drew, then you'll have to compare the Y coordinates to the positions of the horizontal lines to figure out which row. Then you'll need to check its position (left/right) relative to the angled lines to get the column - for that, you'll need either coordinates of the end-points, or equations for the lines.
Yet another option is to store an identical image where each "square" is flood-filled with a different color. You then check the color of the pixel where the user clicked but in this alternate image. This method assumes that it's a fixed image and is the least flexible.
If you have the coordinates of end points of the grid lines then
Try using the inside-outside test for each grid line and find the position
Since this grid is just a 3D view of a 2D grid plane, there is a projective transform that transforms the coordinates on the grid into coordinates on the 2D plane. To find this transform, it is sufficient to mark 4 different points on the plane (say, the edges), assign them coordinates on the 2D plane and solve the resulting linear equation system.