( src: Float32Array, count: number, matrix?: ArrayLike<number>, )
| 212 | * @returns the radius of the smallest origin-centered sphere enclosing the vertices |
| 213 | */ |
| 214 | export function boundingRadius( |
| 215 | src: Float32Array, |
| 216 | count: number, |
| 217 | matrix?: ArrayLike<number>, |
| 218 | ): number { |
| 219 | let maxLenSq = 0; |
| 220 | if (matrix === undefined) { |
| 221 | for (let i = 0; i < count; i++) { |
| 222 | const i3 = i * 3; |
| 223 | const vx = src[i3]; |
| 224 | const vy = src[i3 + 1]; |
| 225 | const vz = src[i3 + 2]; |
| 226 | const lenSq = vx * vx + vy * vy + vz * vz; |
| 227 | if (lenSq > maxLenSq) { |
| 228 | maxLenSq = lenSq; |
| 229 | } |
| 230 | } |
| 231 | return Math.sqrt(maxLenSq); |
| 232 | } |
| 233 | |
| 234 | const m0 = matrix[0]; |
| 235 | const m1 = matrix[1]; |
| 236 | const m2 = matrix[2]; |
| 237 | const m4 = matrix[4]; |
| 238 | const m5 = matrix[5]; |
| 239 | const m6 = matrix[6]; |
| 240 | const m8 = matrix[8]; |
| 241 | const m9 = matrix[9]; |
| 242 | const m10 = matrix[10]; |
| 243 | |
| 244 | for (let i = 0; i < count; i++) { |
| 245 | const i3 = i * 3; |
| 246 | const vx = src[i3]; |
| 247 | const vy = src[i3 + 1]; |
| 248 | const vz = src[i3 + 2]; |
| 249 | const ox = m0 * vx + m4 * vy + m8 * vz; |
| 250 | const oy = m1 * vx + m5 * vy + m9 * vz; |
| 251 | const oz = m2 * vx + m6 * vy + m10 * vz; |
| 252 | const lenSq = ox * ox + oy * oy + oz * oz; |
| 253 | if (lenSq > maxLenSq) { |
| 254 | maxLenSq = lenSq; |
| 255 | } |
| 256 | } |
| 257 | return Math.sqrt(maxLenSq); |
| 258 | } |
| 259 | |
| 260 | const _defaultNormal: XYPoint = { x: 0, y: 0 }; |
| 261 |
no outgoing calls
no test coverage detected