Jump to content

Translate Coordinate List


gsc

Recommended Posts

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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)
)

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...