V I S U A L I Z Z A D I S C U S S I O N E |
arri |
Inserito il - 13 ottobre 2014 : 09:49:51 http://www.lee-mac.com/2dprojection.html
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. |
|
|