← Back to index

Okay, let's break down the derivation of the parking rectangle algorithm in an intuitive, step-by-step manner. We'll focus on the core logic and avoid getting bogged down in heavy matrix notation.

The Goal:

Imagine you have a street segment defined by its center point and direction. You want to draw two parking rectangles, one on each side of the street, with a specified width, height, and offset from the street's center.

The Challenge:

The world isn't flat! We're dealing with latitude and longitude on a (roughly) spherical Earth. So, simply adding distances in meters to coordinates won't work accurately, especially as we move further away from the equator.

The Solution: A Series of Transformations

We'll achieve our goal by performing a sequence of transformations, essentially moving between a simplified "flat-Earth" model for calculations and the real-world geographic coordinates.

1. The "Flat-Earth" Playground: Local Cartesian Coordinates

2. Building the Template Rectangle (Before Scaling and Rotation)

3. Rotating the Rectangle to Align with the Street

4. Stepping Back into the Real World: Geographic Normalization

5. Placing the Rectangle on the Map

6. Creating the Symmetric Rectangle on the Other Side of the Street

In a Nutshell

  1. Build: Create a template rectangle with the desired dimensions, offset from the origin in a simplified, flat coordinate system.
  2. Rotate: Rotate the rectangle to align with the street's direction.
  3. Convert: Transform the rotated coordinates from meters to latitude and longitude.
  4. Place: Translate the rectangle to the actual street center location.
  5. Mirror: Generate a symmetric rectangle on the other side of the street by rotating the rotated coordinates by 180 degrees before converting and translating.

Important Notes

This intuitive explanation should give you a good grasp of the underlying logic of the parking rectangle algorithm. By understanding each step, you can better appreciate the algorithm's strengths, limitations, and how to use it effectively.