Geometric Foundations & Centroid Mathematics
The geometry behind a reading: turning a polygon boundary or a floor plan into a frame with true north straight up and the plan’s centre at its origin, so that every point can be assigned a direction.
Cited for: The texts fix the cardinal directions from the shadow of a gnomon (śaṅku) rather than from a magnetic needle, which is why the engine asks for true north first and treats a compass reading as a correction to be made.
1. True North vs. Magnetic North & Rotation Transforms
A handheld magnetic compass points to the magnetic pole, not to true north, and the two differ by the magnetic declination (D): positive east of true north, negative west of it. In India D runs from about −1.7° to +2.8°, so the larger error is usually the phone and the building: a heading taken indoors near steel can be off by far more than the declination. That is why the studio asks for the sanctioned site plan’s north point first and treats a phone heading as secondary. The classical texts find north from the sun’s shadow with a gnomon (śaṅku).
2D True North Coordinate Rotation Matrix
Rotates polygon vertices around plot centroid into standard cardinal frame
Parameters & variables
θ_measured- Measured north arrow: Clockwise angle from the sheet's up direction to the north arrow as measured(degrees)
D- Magnetic Declination: Local deviation of magnetic north from true north, positive east; zero for a survey or map(degrees)
(C_x, C_y)- Polygon Nābhi Centroid: Cartesian coordinates of the sacred center(meters/feet)
Implementation reference
import math
def rotate_to_true_north(points, centroid, theta_degrees):
rad = math.radians(theta_degrees)
cos_t, sin_t = math.cos(rad), math.sin(rad)
cx, cy = centroid
transformed = []
for x, y in points:
dx, dy = x - cx, y - cy
x_rot = dx * cos_t - dy * sin_t
y_rot = dx * sin_t + dy * cos_t
transformed.append((x_rot, y_rot))
return transformed2. The Shoelace Nābhi (Centroid) Formulation
A rectangular plot has an obvious centre; a trapezoidal, L-shaped or irregular one does not. The Nābhi (Brahma Bindu) is taken as the centroid of the polygon, computed from Green’s theorem by the shoelace formula:
Polygon Signed Area & Centroid Coordinates
Exact geometric center of mass for an arbitrary N-sided closed polygon
Parameters & variables
N- Number of Vertices: Count of boundary polygon vertices (with vertex N = vertex 0)(integer)
A- Signed Polygon Area: Total enclosed floor or plot area(m² or ft²)
(C_x, C_y)- Centroid Coordinates: The exact geometric Nābhi of the site(meters/feet)
Implementation reference
def compute_polygon_centroid(vertices):
"""Computes (A, Cx, Cy) using Shoelace integration."""
n = len(vertices)
area = 0.0
cx = 0.0
cy = 0.0
for i in range(n):
x0, y0 = vertices[i]
x1, y1 = vertices[(i + 1) % n]
cross = (x0 * y1 - x1 * y0)
area += cross
cx += (x0 + x1) * cross
cy += (y0 + y1) * cross
area *= 0.5
cx /= (6.0 * area)
cy /= (6.0 * area)
return abs(area), (cx, cy)3. Ray-Casting & Angular Zone Slicing
Once the Nābhi (C_x, C_y) and the true-north offset θ are established, a point P(x, y) is given its direction by the four-quadrant arctangent, atan2:
Ray-Casting Azimuth to Directional Zone
Parameters & variables
α- Effective Azimuth: Clockwise angle from True North ray(0° to 359.999°)
Zone_16- 16-Directional Sector: 0 (North), 1 (NNE), 2 (NE), ... 15 (NNW)(0 to 15)
Pada_32- 32-Pada Sector: 0 (E1) to 31 (N8), counted clockwise from E1(0 to 31)