mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +00:00
19 lines
634 B
TypeScript
19 lines
634 B
TypeScript
import { N_POINTS } from './constants';
|
|
import { type Point3D } from './types';
|
|
import { fibonacciPoint, normalizeShape } from './utils';
|
|
|
|
// Sphere
|
|
const generateSpherePoints = (radius: number): Point3D[] => {
|
|
const points: Point3D[] = [];
|
|
for (let i = 0; i < N_POINTS; i++) {
|
|
const { theta, phi } = fibonacciPoint(i, N_POINTS);
|
|
points.push({
|
|
x: radius * Math.sin(phi) * Math.cos(theta),
|
|
y: radius * Math.sin(phi) * Math.sin(theta),
|
|
z: radius * Math.cos(phi),
|
|
});
|
|
}
|
|
return points;
|
|
};
|
|
|
|
export const SPHERE_POINTS = normalizeShape(generateSpherePoints(100));
|