# Rotate back across the globe when points cross the IDL #4507

Merged
merged 3 commits into from Oct 24, 2016

## Conversation

Projects
None yet
3 participants
Contributor

### lasalvavida commented Oct 21, 2016

 Fix for #3874.
``` Rotate back across the globe when points cross the IDL ```
``` 827c11a ```
Contributor Author

### lasalvavida commented Oct 21, 2016

 Corrected output:
Contributor

### hpinkos commented Oct 21, 2016

 I don't think that's quite right @lasalvavida. One of the blue rectangles should be rotated. The result should look like the yellow rectangles.
Contributor

### hpinkos commented Oct 21, 2016

 Can you add a unit test for this?
Contributor Author

### lasalvavida commented Oct 21, 2016

 As discussed offline, this is the expected output: `var western2 = createWesternRectangle(0.005);` The blue rectangle is only rotated a small amount.

### hpinkos added the bug bash label Oct 21, 2016

Contributor Author

### lasalvavida commented Oct 21, 2016

 Adding a test now. Just to be clear, the crux of this issue is that the rectangle has its northwest corner on the opposite of the IDL from its center. So, when we do the following: ` nwCartesian = Cartesian3.subtract(nwCartesian, centerCartesian, nwCartesian);` Instead of getting the very small difference between them, we subtract a negative value, producing a large offset which blows up small rotations to the point where it causes a translation.

### hpinkos reviewed Oct 21, 2016

 @@ -118,6 +118,10 @@ define([ granYSin = granularityY * sinRotation; granXSin = granularityX * sinRotation; if (center.longitude < nwCorner.longitude) { center.longitude += 2 * Math.PI;

#### hpinkos Oct 21, 2016

Contributor

do `CesiumMath.TWO_PI`

Contributor

### hpinkos commented Oct 21, 2016

 Looks good to me @lasalvavida! I just had that one comment.
``` Added test and use CesiumMath.2_PI ```
``` c779fc2 ```
Contributor Author

### lasalvavida commented Oct 21, 2016

``` Fixed constant name ```
``` 2fe71f0 ```
Contributor

### hpinkos commented Oct 24, 2016

 Great, thanks @lasalvavida!

### hpinkos merged commit `8ba579b` into AnalyticalGraphicsInc:master Oct 24, 2016 1 check passed

#### 1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Member

### pjcozzi commented Oct 25, 2016

 @hpinkos please update CHANGES.md in master.

Closed