Skip to content

Commit a5cf6fa

Browse files
committed
change pseudocode to Typescript
1 parent 7f1a442 commit a5cf6fa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

developer-guides/center-point.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ The `Transform` variables `center`, `elevation`, `zoom`, `pitch`, `bearing`, and
99

1010
Together, `zoom`, `elevation`, and `pitch` set the altitude of the camera:
1111

12-
Pseudocode (implemented in `MercatorTransform::_calcMatrices()`):
13-
```
14-
cameraToCenterDistancePixels = 0.5 / tan(fov/2) * viewportHeight
15-
pixelPerMeter = mercatorUnitsPerMeter(center.lat) * worldSize
16-
cameraToCenterDistanceMeters = cameraToCenterDistancePixels / pixelsPerMeter
17-
cameraAltitude = centerElevation + cameraToCenterDistanceMeters*cos(pitch)
12+
See `MercatorTransform::getCameraAltitude()`:
13+
```typescript
14+
getCameraAltitude(): number {
15+
const altitude = Math.cos(this.pitchInRadians) * this._cameraToCenterDistance / this._helper._pixelPerMeter;
16+
return altitude + this.elevation;
17+
}
1818
```
1919

2020
![image](assets/center-point_nominal.png)

0 commit comments

Comments
 (0)