Skip to main content
Chapter 2

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.

Mayamata

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.

The wording is not quoted here: the locus has not been checked against an edition.

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

θ = (θ_measured − D) mod 360°
x' = (x - C_x) cos(θ) - (y - C_y) sin(θ)
y' = (x - C_x) sin(θ) + (y - C_y) cos(θ)
θ is the drawing's true-north offset: the clockwise angle from the sheet's up direction to the north arrow, taken from a survey or map as it is or, if it was laid off with a compass, less the declination D. Every point (x, y) is translated so the centroid lies at (0, 0) and rotated counter-clockwise by θ, which brings true north to the positive Y-axis.
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 transformed

2. 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

Complexity: O(N) single-pass linear time
A = (1/2) Σ [x_i × y_{i+1} - x_{i+1} × y_i] (for i = 0 to N-1)
C_x = (1 / 6A) Σ [(x_i + x_{i+1}) × (x_i × y_{i+1} - x_{i+1} × y_i)]
C_y = (1 / 6A) Σ [(y_i + y_{i+1}) × (x_i × y_{i+1} - x_{i+1} × y_i)]
This is the area centroid, the point the sixteen zones are measured round. On an L, C or U-shaped plan it can fall outside the plan; the engine then reports the interior point nearest to it, and says so (method nearest_interior).
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

α_raw = atan2(x - C_x, y - C_y) × (180° / π)
α = (α_raw - θ_north + 360°) mod 360°
Zone_16 = ⌊ (α + 11.25°) / 22.5° ⌋ mod 16
Pada_32 = ⌊ ((α − 45°) mod 360°) / 11.25° ⌋ (E1 = 0 … N8 = 31)
The half-step offset of +11.25° puts each cardinal direction at the centre of its 22.5° sector (north spans 348.75° to 11.25°). The pada formula is the angular approximation: it counts 11.25° sectors from 45°, where E1 begins, and is exact only for a square plot. The studio counts a door along its wall, which is how the texts count it.
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)