* Apply rotation to a 3D point (same rotation as marker/arc shaders) * Uses rot * p (matrix times column vector) for world-to-view transformation * @param {[number, number, number]} p * @param {number} theta * @param {number} phi * @returns {[number, number, number]}
(p)
| 269 | * @returns {[number, number, number]} |
| 270 | */ |
| 271 | function applyRotation(p) { |
| 272 | const cx = Math.cos(theta) |
| 273 | const cy = Math.cos(phi) |
| 274 | const sx = Math.sin(theta) |
| 275 | const sy = Math.sin(phi) |
| 276 | |
| 277 | const aspect = canvas.width / canvas.height |
| 278 | |
| 279 | // Rotated coordinates |
| 280 | const rx = cy * p[0] + sy * p[2] |
| 281 | const ry = sy * sx * p[0] + cx * p[1] - cy * sx * p[2] |
| 282 | const rz = -sy * cx * p[0] + sx * p[1] + cy * cx * p[2] |
| 283 | |
| 284 | return [ |
| 285 | ((rx / aspect) * scaleOpt + offsetOpt[0] * scaleOpt * dpr / canvas.width + 1) / 2, |
| 286 | (-ry * scaleOpt + offsetOpt[1] * scaleOpt * dpr / canvas.height + 1) / 2, |
| 287 | rz >= 0 || rx * rx + ry * ry >= 0.64, // visible if in front OR outside globe silhouette |
| 288 | ] |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Project a location to screen coordinates |
no outgoing calls
no test coverage detected
searching dependent graphs…