gsc Posted October 10, 2018 Share Posted October 10, 2018 Hi, I want to translate a coordinate list with LISP. an example is attached in DWG format The coordinates are extracted of the cyan polyline, but they need to be translated to the cyan dashed polyline The Original Centerpoint is (-33.665 59.430 0) = the point object in the DWG Cyan Polyline Coordinate list is ((-36.8783 63.7139 0.0) (-38.8052 60.3764 0.0) (-37.923 57.0839 0.0) (-34.8149 54.2349 0.0) (-29.7626 55.5886 0.0) (-28.3876 57.9703 0.0) (-29.4948 62.1025 0.0) (-33.7415 64.5544 0.0) (-36.8783 63.7139 0.0)) New Centerpoint (0 0 0) The coordinates also need to be rotated 90 degrees clockwise How do I do this? Greetzzz, Gerben Example.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 10, 2018 Share Posted October 10, 2018 (edited) Draw object and move and rotate so much easier. it looks like only 2-3 parts. Or just copy and get-co-ords. Edited October 10, 2018 by BIGAL Quote Link to comment Share on other sites More sharing options...
gsc Posted October 10, 2018 Author Share Posted October 10, 2018 I know...however I (or better the future user using this lisp) need to write an XML file with WKT points from this cad drawing. This is a ship (hull) with a part (green and cyan lines) that is actually on that position, but the XML needs the coordinates of this object relative to 0,0 pointing to the north (rotated 90 degrees clockwise) So I figured already out with the distance and angle function to move the cyan line to 0,0, but i still need some code that rotates the object at 0,0 with 90 degrees clockwise to get the coordinates Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 10, 2018 Share Posted October 10, 2018 Translate using: (setq vec '(-33.665 59.430 0) lst '((-36.8783 63.7139 0.0) (-38.8052 60.3764 0.0) (-37.923 57.0839 0.0) (-34.8149 54.2349 0.0) (-29.7626 55.5886 0.0) (-28.3876 57.9703 0.0) (-29.4948 62.1025 0.0) (-33.7415 64.5544 0.0) (-36.8783 63.7139 0.0)) ) (setq lst (mapcar '(lambda ( x ) (mapcar '- x vec)) lst)) Rotate (about 0,0) using: (setq mat '((0 1 0) (-1 0 0) (0 0 1)) lst (mapcar '(lambda ( x ) (mxv mat x)) lst) ) ;; Matrix x Vector - Vladimir Nesterovsky ;; Args: m - nxn matrix, v - vector in R^n (defun mxv ( m v ) (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m) ) Quote Link to comment Share on other sites More sharing options...
gsc Posted October 10, 2018 Author Share Posted October 10, 2018 That is much more efficient, thanx man! I also figured it out an hour ago with a double polar subroutine. The first polar to move the lst from vec to 0,0 The second polar to rotate the updated lst around 0,0 with 90 or 270 degrees (if the object is on the other side of the ship) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.