Pt translation...

Discussion in 'AutoCAD' started by Devin, Jul 23, 2003.

  1. Devin

    Devin Guest

    Can anyone point me to a good pt translation routine that translates a 3d
    point given two 3d points as the translation vector.

    TIA,

    Devin
     
    Devin, Jul 23, 2003
    #1
  2. Devin

    Devin Guest

    Got it...

    (defun vector_translate ( pt v1 v2 / i j vec )
    (setq
    vec :)vector_2p v1 v2)
    )
    (if
    vec
    (setq
    pt
    (mapcar
    '(lambda (i j)
    (+ i J)
    )
    pt
    vec
    )
    )
    )
    )



    (defun :VECTOR_2P (pt1 pt2 / )
    (if(equal pt1 pt2 1e-10)
    nil
    (mapcar (function (lambda (i j) (- j i))) pt1 pt2)
    )
    )

    Devin
     
    Devin, Jul 23, 2003
    #2
  3. You can define a vector by simply subtracting the beginning point from the
    end point. Then simply add that vector to the existing point to obtain the
    new point.

    (defun GetVector (startPoint endPoint)
    (mapcar '- endPoint startPoint)
    )

    (defun MovePoint (vector point)
    (mapcar '+ point vector)
    )

    (MovePoint (GetVector '(3 3 0) '(5 5 0)) '(1 2 0))
    (3 4 0)
     
    Bobby C. Jones, Jul 23, 2003
    #3
  4. Devin

    Doug Broad Guest

    Simplification:
    (defun vector_translate (pt v1 v2)
    (mapcar '+ pt v1 (mapcar '- v2)))
     
    Doug Broad, Jul 23, 2003
    #4
  5. Devin

    Doug Broad Guest

    Correction:
    (defun vector_translate (pt v1 v2)
    (mapcar '+ pt v2 (mapcar '- v1)))
     
    Doug Broad, Jul 23, 2003
    #5
  6. Devin

    Devin Guest

    Thanks Bobby,

    That's very simple for me to understand. Which is what I need.

    Devin
     
    Devin, Jul 23, 2003
    #6
  7. Devin

    Devin Guest

    Thanks Luis,

    Will that work for 3d points?

    Devin
     
    Devin, Jul 23, 2003
    #7
  8. Devin

    Devin Guest

    Wouldn't it be rather...

    (defun vector_translate (pt v1 v2)
    (mapcar '+ pt (mapcar '- v1 v2))
    )
     
    Devin, Jul 23, 2003
    #8
  9. Devin

    Devin Guest

    Correction...

    (defun vector_translate (pt v1 v2)
    (mapcar '+ pt (mapcar '- v2 v1))
    )
     
    Devin, Jul 23, 2003
    #9
  10. Devin

    Devin Guest

    Oops forgot to thank you for the simplification. I think it will actually
    work better than what I had as it will work when the vector is (0,0,0).

    Thanks,

    Devin
     
    Devin, Jul 23, 2003
    #10
  11. Devin

    Doug Broad Guest

    That version would be as good as the one
    I posted. My version uses negation rather than
    subraction. Both versions should be equally fast.
     
    Doug Broad, Jul 23, 2003
    #11
  12. Devin

    Devin Guest

    O.K. my bad. Guess I should have tested it.

    Thanks,

    Devin
     
    Devin, Jul 23, 2003
    #12
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.