Skip to content

Allow logic for converting fiducial distances to location #14

Description

@adehecq

Some calibration reports, such as the one used for the Icelandic 1986 dataset, provide the distance between pairs of fiducial markers rather than actual location (see image below). Currently, this is not handled in HIPP.

Image

It is likely possible to convert this info into a distance from PPA or center point. Here is a possible suggestion, based on trilateration found by @friedrichknuth.
This would need to be checked thoroughly though.

import math

# 1. Input Distances
d12 = 212.008
d13 = 299.823  # Diagonal
d23 = 212.004
d24 = 299.810  # Diagonal
d34 = 212.004
d41 = 211.993

# 2. Place points relative to each other (Initial Cartesian CRS)
# Point 1 is at the origin
p1 = (0.0, 0.0)

# Point 2 is on the X-axis
p2 = (d12, 0.0)

# Point 3 trilateration from P1 and P2
# Using law of cosines / circle intersection formula:
# x = (d13^2 - d23^2 + d12^2) / (2 * d12)
x3 = (d13**2 - d23**2 + d12**2) / (2 * d12)
y3 = math.sqrt(max(0, d13**2 - x3**2))
p3 = (x3, y3)

# Point 4 trilateration from P1 and P2
# x = (d14^2 - d24^2 + d12^2) / (2 * d12)
x4 = (d41**2 - d24**2 + d12**2) / (2 * d12)
y4 = math.sqrt(max(0, d41**2 - x4**2))
p4 = (x4, y4)

points = [p1, p2, p3, p4]

# 3. Compute Centroid (Center of all four points)
cx = sum(p[0] for p in points) / 4
cy = sum(p[1] for p in points) / 4

# 4. Translate points to center them at (0, 0)
centered_points = [(p[0] - cx, p[1] - cy) for p in points]

# Display Results
print(f"{'Point':<10} | {'X Coordinate':<15} | {'Y Coordinate':<15}")
print("-" * 45)
for i, (x, y) in enumerate(centered_points, 1):
    print(f"Point {i:<5} | {x:>15.4f} | {y:>15.4f}")

# Validation: Check internal distances to ensure geometry is preserved
def dist(pa, pb):
    return math.sqrt((pa[0]-pb[0])**2 + (pa[1]-pb[1])**2)

print("\nValidation (Calculated vs Input):")
print(f"1-2: {dist(centered_points[0], centered_points[1]):.3f} (Expected: {d12})")
print(f"3-4: {dist(centered_points[2], centered_points[3]):.3f} (Expected: {d34})")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions