If the end result of this gibberish is anything short of cold fusion I'm going to be bitterly disappointed.
Announcement
Collapse
No announcement yet.
So you're think you're good at math?
Collapse
X
-
I bet it's a GPS/mapping utility on a phone.12-17-10 Mohamed Bouazizi NEVER FORGET
Stadtluft Macht Frei
Killing it is the new killing it
Ultima Ratio Regum
Comment
-
It's a desktop web app for the company to define various "tiers" of geographic regions. We're overhauling our back-end to be fully geocentric with polygonal search. Instead of just looking for a given business within X kilometers of the user's current location, it'll use the defined polygon to search within. This is useful for places like Montreal which has something called a "river" that may be annoying in crossing when getting results.
The multipliers exist because if there's few or no results within the polygon, it'll multiply and multiply the polygon size until it reaches a satisfactory number of results. I didn't write the business specs on this...
This tool allows Frenchmen in Quebec to define polygons throughout Canada and then export the polygonal data to our database servers."The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
Originally posted by KrazyHorse View PostAsher, I'm not sure your problem is well-formulated....
An example for why I say this is as follows: Take as your polygon a square "centered" at the north pole with "radius" (distance from north pole to each vertex) of pi/2*R where R is the Earth's radius
First off, the location of the "centroid" is ambiguous; is it the north pole or the south pole?
Secondly, if you "double" this polygon you either end up with 4 overlapping points at the south pole (if you assumed the original polygon was centered at the north pole) or at the north pole (if you assumed a center at the south pole)
Either way, the side lengths have shrunk under a "doubling".
For less extreme cases, it is ALWAYS true that "doubling" the polygon using the method you claim here will scale the side lengths by a factor LESS than 2. This is because a sphere is a surface of constant positive curvature. More worryingly, the side lengths will all change by different factors (sides closer to the centroid will increase in length more than sides far from the centroid)
In other words, if I "double" an equilateral triangle of sides 500 km I will end up, using your method, with a triangle of sides less than 1000 km, and for more complex figures not even the ratio of side lengths is constant.
What is the purpose of this function? We need to know what the appropriate sense of "scale" is; is it side lengths? Is it "radius"? Is it something else?"The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
When presented with the specs I argued that multiplying the polygons made no sense. They're being defined around specific geographic landmarks or attributes, so if we need to get more results than that we may as well fall-back to simple radial searches. There's no point to multiplying the polygon if we're no longer adhering to the geographic landmarks.
But as I said, they were Frenchmen liberal arts-grads and did not understand."The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
Well, you're basically looking to scale a polygon in a conformal (angle preserving) map to a cartesian space (i.e the Mercator projection). The easy way to conceptualize this (and minimize error) would probably be to apply the conformal map, scale the polygon, then apply the inverse of the conformal map. This way, BTW, you get every point on the polygon fairly easily."Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way. "
-Bokonon
Comment
-
Ramo, I don't think conformal mapping is vary important here...Last edited by KrazyHorse; November 26, 2009, 11:44.12-17-10 Mohamed Bouazizi NEVER FORGET
Stadtluft Macht Frei
Killing it is the new killing it
Ultima Ratio Regum
Comment
-
No. No, I do not think I am good at math.
Comment
-
Originally posted by KrazyHorse View PostRamo, I don't think conformal mapping is vary important here..."Beware of the man who works hard to learn something, learns it, and finds himself no wiser than before. He is full of murderous resentment of people who are ignorant without having come by their ignorance the hard way. "
-Bokonon
Comment
-
Here's the code excerpt (in Javascript) to see how I've done it:
Code:var d = distHaversine(centre, point); d = d * mult; var brng = bearing(centre, point); var newpoint = destPoint(centre, brng, d); function distHaversine(point1, point2) { var lat1 = point1.lat(); var lon1 = point1.lng(); var lat2 = point2.lat(); var lon2 = point2.lng(); var R = 6371; // earth's mean radius in km var dLat = (lat2-lat1).toRad(); var dLon = (lon2-lon1).toRad(); lat1 = lat1.toRad(), lat2 = lat2.toRad(); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon/2) * Math.sin(dLon/2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; return d; } function bearing(point1, point2) { var lat1 = point1.lat(); var lon1 = point1.lng(); var lat2 = point2.lat(); var lon2 = point2.lng(); lat1 = lat1.toRad(); lat2 = lat2.toRad(); var dLon = (lon2-lon1).toRad(); var y = Math.sin(dLon) * Math.cos(lat2); var x = Math.cos(lat1)*Math.sin(lat2) - Math.sin(lat1)*Math.cos(lat2)*Math.cos(dLon); return Math.atan2(y, x).toBrng(); } function destPoint(centre, brng, d) { var R = 6371; // earth's mean radius in km var lat1 = centre.lat().toRad(), lon1 = centre.lng().toRad(); brng = brng.toRad(); var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) + Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) ); var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2)); lon2 = (lon2+Math.PI)%(2*Math.PI) - Math.PI; // normalise to -180...+180 if (isNaN(lat2) || isNaN(lon2)) return null; return new GLatLng(lat2.toDeg(), lon2.toDeg()); } // overloads // convert degrees to radians Number.prototype.toRad = function() { return this * Math.PI / 180; } // convert radians to degrees (signed) Number.prototype.toDeg = function() { return this * 180 / Math.PI; } // convert radians to degrees (as bearing: 0...360) Number.prototype.toBrng = function() { return (this.toDeg()+360) % 360; }
"The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
And thanks for everyone's help. I'm just thrilled there wasn't a simple one-line solution I was missing. I'm not totally retarded."The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
If I were given that problem spec I'd just pretend that the world was flat - the user's polygon is imprecise so we can fudge on expanding it. Also, if the polygon is "centered" around a specific location ie the user's location then it may make sense to pretend that location is the centroid when expanding the polygon.<p style="font-size:1024px">HTML is disabled in signatures </p>
Comment
-
Originally posted by loinburger View PostIf I were given that problem spec I'd just pretend that the world was flat - the user's polygon is imprecise so we can fudge on expanding it. Also, if the polygon is "centered" around a specific location ie the user's location then it may make sense to pretend that location is the centroid when expanding the polygon.
So the polygons are never centered around the end-user, the end user is just within a polygon defined by the user of my tool (heh heh).
The polygons are expanded irrespective of the end-user's position, they're expanded upon their geographic centre as defined by the tool-user.
The polygons defined by my tool are being exported to SQL Server 2008, where my sexy new geolocation-enabled database can use the polygons to perform searches against our data store. The back-end team for this is stupid and couldn't comprehend how to do polygon expansion, so now I get to implement it in the front-end and then export an array of pre-expanded polygons for their stupid asses."The issue is there are still many people out there that use religion as a crutch for bigotry and hate. Like Ben."
Ben Kenobi: "That means I'm doing something right. "
Comment
-
Cool, I'm glad I was on the right track.
This is actually similar to some stuff we had to do in Astro way back when. We were always working in Polars (RA + Dec).Scouse Git (2) La Fayette Adam Smith Solomwi and Loinburger will not be forgotten.
"Remember the night we broke the windows in this old house? This is what I wished for..."
2015 APOLYTON FANTASY FOOTBALL CHAMPION!
Comment
Comment