MCB
MCB

Reputation: 2073

How to circumscribe a sphere with N trapezoidal panels

not sure if this belongs here or on the mathematics exchange.

So I have a sphere of radius r. I want to circumscribe it in tiles/ panels which I can then populate with data from the real world organized by latitude and longitude. But I'm stuck on how to generate the tiles.

Thank you

Upvotes: 0

Views: 37

Answers (1)

aptriangle
aptriangle

Reputation: 1428

If you are tessellating a sphere into trapezoids, the sphere is divided into rings and then trapezoids are drawn between those rings. I've made a working example here that displays the generated sphere (excuse the typescript, but it is easier to make fiddles). https://jsfiddle.net/uyrk1vb8/

The points are calculated like this, where ringAngle varies from -π/2 to π/2 and the circleAngle varies from 0 to 2π.

function calculatePoint(ringAngle: number, circleAngle: number, radius: number): Point {
  const ringRadius = Math.cos(ringAngle) * radius;
  const x = Math.cos(circleAngle) * ringRadius;
  const y = Math.sin(circleAngle) * ringRadius;
  const z = Math.sin(ringAngle) * radius;
  return {x, y, z};
}

Then trapezoids are created by connecting those points. The fiddle provides an example of this in the function calculateTrapezoid.

Upvotes: 1

Related Questions