2D Projection

Function Syntax 2dpro
Current Version 1.0
Download 2DProjectionV1-0.lsp
View HTML Version 2DProjectionV1-0.html

Program Description

Inspired by the superb Projective2D application published by the talented programmer Sean Tessier, here I present an open-source AutoLISP program offering similar functionality.

This program provides the user with a means of applying a projective transformation (also known as a homography, collineation, or less technically, a 'perspective' transformation), projecting a selected set of planar objects from one reference frame (or projective space) to another.

Upon issuing the command syntax 2dpro at the AutoCAD command-line, the user is prompted to select a set of 2D coplanar objects to be projected. This selection is restricted to Arcs, Circles, Elipses, Lines, LWPolylines, 2D (Heavy) Polylines, 2D Splines & Points.

The user is then prompted to select a source reference frame & a destination reference frame. For each of these prompts, the program requires the user to select a closed planar polyline (LWPolyline) with four non-collinear vertices. Following each selection, the program will ensure the points defining the reference frame are counter-clockwise oriented with the points ordered such that the lower-left vertex appears first.

Following valid user responses, the program will then convert the four 2D points defining each reference frame into homogeneous coordinates, and will calculate the transformation matrix to map from the source reference frame (or projective space) to the destination reference frame.

The program will then iterate over the set of selected objects and, for each object, will calculate a 2D point set describing or (in the case of curved objects) approximating the object. Each point is then converted to homogeneous coordinates and mapped to the destination reference frame using the tranformation matrix, before being converted back to cartesian coordinates.

The program will then generate either a Point, Line or LWPolyline from the mapped point(s) with properties matching those of the original object.


Below are two examples demonstrating the use of the program to project a set of objects from an orthogonal reference frame to a skewed perspective, and then from one skewed perspective to another. Please note that the text in the following example was created using the Express Tools TXTEXP command and is hence composed of lines & polylines.

Example 1

2D Projection Example 1

Example 2

2D Projection Example 2

Example 3 (for fun!)

2D Projection Example 3

Instructions for Running

Please refer to How to Run an AutoLISP Program.


increase · reset · decrease

Designed & Created by Lee Mac © 2010