Tests for Ox.getCenter and Ox.getDistance fail in Chrome #246

Open
opened 2014-08-19 12:05:50 +00:00 by rlx · 2 comments
Owner

Fails in Chrome 36.0.1985.143

Works in Firefox 31.0

Fails in Chrome 36.0.1985.143 Works in Firefox 31.0
rlx added the
Ox
label 2014-08-19 12:05:50 +00:00
rlx self-assigned this 2014-08-19 12:05:50 +00:00
rlx added the
severity: major
defect
0.1
0.1
labels 2014-08-19 12:05:50 +00:00
rlx changed title from Tests for Ox.getCenter and Ox.getDistance fail to Tests for Ox.getCenter and Ox.getDistance fail in Chrome 2014-08-19 14:02:47 +00:00
Owner

Chrome fails for the following calls, Firefox and Python return same results in those cases:

> Math.sin(-0.7853981633974483)
// Chrome:  -0.7071067811865474
// Firefox: -0.7071067811865475
// Python:  -0.7071067811865475

> Math.cos(-0.7853981633974483)
// Chrome:  0.7071067811865475
// Firefox: 0.7071067811865476
// Python:  0.7071067811865476

> Math.cos(0.7853981633974483)
// Chrome:  0.7071067811865475
// Firefox: 0.7071067811865476
// Python:  0.7071067811865476

Details:

function deg(point) {
        return Ox.map(point, function(val) {
            return Ox.mod(Ox.deg(val) + 180, 360) - 180;
        });
}

function rad(point) {
    return Ox.map(point, function(val) {
        return Ox.rad(val);
    });
}

pointA = {lat: -45, lng: -90};
pointB = {lat: 45, lng: 90};

pointA = rad(pointA);
//Object { lat: -0.7853981633974483, lng: -1.5707963267948966 }

pointB = rad(pointB);
// Object { lat: 0.7853981633974483, lng: 1.5707963267948966 }

Math.acos(
    Math.sin(pointA.lat) * Math.sin(pointB.lat)
    + Math.cos(pointA.lat) * Math.cos(pointB.lat)
    * Math.cos(pointB.lng - pointA.lng)
)

// Chrome:  3.1415926325163688
// Firefox: 3.141592653589793

// pointA.lat = -0.7853981633974483
// pointB.lat =  0.7853981633974483

Math.sin(pointA.lat) * Math.sin(pointB.lat)
// Chrome:  -0.49999999999999983
// Firefox: -0.4999999999999999
Math.cos(pointA.lat) * Math.cos(pointB.lat)
// Chrome:  0.4999999999999999
// Firefox: 0.5000000000000001
Math.cos(pointB.lng - pointA.lng)
// Chrome:  -1
// Firefox: -1

Math.sin(-0.7853981633974483)
// Firefox: -0.7071067811865475
// Chrome:  -0.7071067811865474
// Python:  -0.7071067811865475

Math.sin(0.7853981633974483)
// Firefox: 0.7071067811865475
// Chrome:  0.7071067811865475
// Python:  0.7071067811865475

Math.cos(-0.7853981633974483)
// Firefox: 0.7071067811865476
// Chrome:  0.7071067811865475
// Python:  0.7071067811865476

Math.cos(0.7853981633974483)
// Firefox: 0.7071067811865476
// Chrome:  0.7071067811865475
// Python:  0.7071067811865476
Chrome fails for the following calls, Firefox and Python return same results in those cases: ``` > Math.sin(-0.7853981633974483) // Chrome: -0.7071067811865474 // Firefox: -0.7071067811865475 // Python: -0.7071067811865475 > Math.cos(-0.7853981633974483) // Chrome: 0.7071067811865475 // Firefox: 0.7071067811865476 // Python: 0.7071067811865476 > Math.cos(0.7853981633974483) // Chrome: 0.7071067811865475 // Firefox: 0.7071067811865476 // Python: 0.7071067811865476 ``` Details: ``` function deg(point) { return Ox.map(point, function(val) { return Ox.mod(Ox.deg(val) + 180, 360) - 180; }); } function rad(point) { return Ox.map(point, function(val) { return Ox.rad(val); }); } pointA = {lat: -45, lng: -90}; pointB = {lat: 45, lng: 90}; pointA = rad(pointA); //Object { lat: -0.7853981633974483, lng: -1.5707963267948966 } pointB = rad(pointB); // Object { lat: 0.7853981633974483, lng: 1.5707963267948966 } Math.acos( Math.sin(pointA.lat) * Math.sin(pointB.lat) + Math.cos(pointA.lat) * Math.cos(pointB.lat) * Math.cos(pointB.lng - pointA.lng) ) // Chrome: 3.1415926325163688 // Firefox: 3.141592653589793 // pointA.lat = -0.7853981633974483 // pointB.lat = 0.7853981633974483 Math.sin(pointA.lat) * Math.sin(pointB.lat) // Chrome: -0.49999999999999983 // Firefox: -0.4999999999999999 Math.cos(pointA.lat) * Math.cos(pointB.lat) // Chrome: 0.4999999999999999 // Firefox: 0.5000000000000001 Math.cos(pointB.lng - pointA.lng) // Chrome: -1 // Firefox: -1 Math.sin(-0.7853981633974483) // Firefox: -0.7071067811865475 // Chrome: -0.7071067811865474 // Python: -0.7071067811865475 Math.sin(0.7853981633974483) // Firefox: 0.7071067811865475 // Chrome: 0.7071067811865475 // Python: 0.7071067811865475 Math.cos(-0.7853981633974483) // Firefox: 0.7071067811865476 // Chrome: 0.7071067811865475 // Python: 0.7071067811865476 Math.cos(0.7853981633974483) // Firefox: 0.7071067811865476 // Chrome: 0.7071067811865475 // Python: 0.7071067811865476 ```
Owner
This might be fixed in latest v8 ([Commit from Aug 6](https://code.google.com/p/v8/source/detail?r=22918):) <https://code.google.com/p/v8/issues/detail?id=3006> <https://bugzilla.mozilla.org/show_bug.cgi?id=967709#c33>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: 0x2620/oxjs#246
No description provided.