homography-transform
Version:
A robust TypeScript implementation of homography-based transformation between 2D planes, ideal for computer vision and image mapping
36 lines (31 loc) • 702 B
text/typescript
export interface Point {
x: number;
y: number;
}
export class Plane {
constructor(
private readonly width: number,
private readonly height: number
) {
if (width <= 0 || height <= 0) {
throw new Error('Plane dimensions must be positive numbers');
}
}
public getWidth(): number {
return this.width;
}
public getHeight(): number {
return this.height;
}
public isPointInBounds(point: Point): boolean {
return (
point.x >= 0 &&
point.x <= this.width &&
point.y >= 0 &&
point.y <= this.height
);
}
public toString(): string {
return `Plane(${this.width}x${this.height})`;
}
}