rotating a point along an axis...

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

  1. Devin

    Devin Guest

    I can't remember who it was, but someone mentioned something about point
    transformations. What I want to do is rotate a point along an axis defined
    by two points a given angle.

    Thanks for any help,

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

    BillZ Guest

    Rotate3d method.

    Syntax from the help file:

    object.Rotate3D Point1, Point2, RotationAngle

    I haven't used this yet but soon.



    Bill
     
    BillZ, Jul 17, 2003
    #2
  3. Devin

    Devin Guest

    That's the stuff.  Thanks Bill!



     



    Devin
     
    Devin, Jul 17, 2003
    #3
  4. Devin

    Mark Propst Guest

    Are you talking about transforming a point coordinate or rotating a point
    entity(as in BillZ's answer)?
     
    Mark Propst, Jul 17, 2003
    #4
  5. This is a "translation" from a C function defined in the "CAL" pseudo ALisp
    command . . .


    (defun :SQR (n)
    (if (> n 46340)
    (* (float n) n)
    (* n n)
    )
    )

    (defun :VECTOR_MODULE (v / X Y Z)
    (setq x (car v) y (cadr v) z (caddr v) )
    (if (not z) (setq z 0.0))
    (sqrt (+ (* z z) (* x x) (* y y) ) )
    )


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


    (defun :ROTATE_POINT_AROUND_AXIS (px angx p1 p2
    /
    CADDRP CADRP CARP COSA COSB COSC LEN LENXY
    N P PZ SINA SINB SINC
    )
    (setq *EPS10* 1.0e-010)

    (setq n :)VECTOR_2P p1 p2)
    lenxy (sqrt (+ :)SQR (car n)) :)SQR (cadr n))))
    )
    (if (> lenxy *EPS10*)
    (setq cosa (/ (car n) lenxy) sina (/ (cadr n) lenxy) )
    (setq cosa 1.0 sina 0.0 )
    )
    (setq len :)VECTOR_MODULE n)
    cosb (/ (caddr n) len)
    sinb (/ lenxy len)
    cosc (cos angx)
    sinc (sin angx)
    p :)VECTOR_2P p1 px)
    carp (car p)
    cadrp (cadr p)
    caddrp (caddr p)
    px (+ (* cosa carp) (* sina cadrp))
    cadrp (+ (* sina -1.0 carp) (* cosa cadrp))
    carp px
    pz (+ (* cosb caddrp)(* sinb carp) )
    carp (+(* -1.0 sinb caddrp)(* cosb carp))
    caddrp pz
    px (-(* cosc carp) (* sinc cadrp))
    cadrp (+(* sinc carp) (* cosc cadrp))
    carp px
    pz (-(* cosb caddrp)(* sinb carp))
    carp (+(* sinb caddrp)(* cosb carp))
    caddrp pz
    px (-(* cosa carp)(* sina cadrp))
    cadrp (+(* sina carp)(* cosa cadrp))
    carp px
    )
    (list
    (+ carp (car p1))
    (+ cadrp (cadr p1))
    (+ caddrp (caddr p1))
    )

    )


    domenico
     
    Domenico Maria Pisano, Jul 17, 2003
    #5
  6. Devin

    Devin Guest

    Thanks Domenico,

    That is going to come in handy, the only thing now is how to get the angle
    of three 3d points. angle: p1 p2 p3.

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

    Devin Guest

    Hi Joe,

    I thought that the angle command is only good for angles about the x axis.
    I need to find the absolute angle between < p1 p2 p3 allowing for all three
    axis. Will this still work?

    Thanks,

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

    Joe Burke Guest

    Devin,

    Sorry, I didn't read the messages carefully. @delta is a 2D function. I did
    think that seemed like too simple an answer.

    Joe
     
    Joe Burke, Jul 17, 2003
    #8
  9. .. . . try this and let me know if it works well . . .


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



    (defun :ACOS (x)
    ;
    (cond
    ((equal x -1.0 1e-06) (setq x -1.0) )
    ((equal x 1.0 1e-06) (setq x 1.0) )
    ((> x 1.0) (setq x nil ) )
    ((< x -1.0) (setq x nil ) )
    )
    (if x
    (atan (sqrt (- 1.0 (expt x 2.0))) x)
    nil
    )
    )


    (defun :VECTOR_SCALAR_PRODUCT (v1 v2)
    (+ (* (car v1)(car v2)) (* (cadr v1)(cadr v2)) (* (caddr v1)(caddr
    v2)) )
    )


    (defun :VECTOR_MODULE (v / X Y Z)
    (setq x (car v) y (cadr v) z (caddr v) )
    (if (not z) (setq z 0.0))
    (sqrt (+ (* z z) (* x x) (* y y) ) )
    )


    ; returns intenal angle (radiants) for 3 3d points
    (defun :ANG2D_3P3D_I (p1 px p3 / V1 V3)
    (setq v1 :)VECTOR_2P px p1))
    (if v1
    (setq v3 :)VECTOR_2P px p3))
    )
    (if v3
    (if (not (equal v1 v3 1e-12))
    :)ACOS
    (/
    :)VECTOR_SCALAR_PRODUCT v1 v3)
    (* :)VECTOR_MODULE v1) :)VECTOR_MODULE v3) )
    )
    )
    0.0
    )
    nil
    )
    )



    domenico
     
    Domenico Maria Pisano, Jul 18, 2003
    #9
  10. Devin

    BillZ Guest

    Also:
    Here is a program that came with AutoCAD (R10 I think).
    Called Spiral. Will Make a 2d or 3d spiral with giver parameters. It so simple that I can't understand it but have always thought that it must contain the math needed to figure a 3d point around an axis.

    HTH

    Bill
     
    BillZ, Jul 18, 2003
    #10
  11. Devin

    Devin Guest

    Thanks Domenico,

    It will be a little time before I can put them into play. Hopefully short.
    I'm trying to make a function to create a ucs given three points. The vla
    functions for adding the ucs require a base pt, x-direction-vector and
    y-direction-vector. I think that the three points have to be perpendicular.
    But the points I need to supply aren't perpendicular so I must make them
    that way, via your functions.

    If I have three points defining an x-y axis, how do I get a fourth point up
    1.0 units in the z direction? I think that would give me the axis for the
    3drotate of the point. Perhaps we can create this function together.

    Thanks, you've been a big help!

    Devin
     
    Devin, Jul 18, 2003
    #11
  12. If you will use my routenes, you will not need no UCS manipulation.
    My code works (if it works . . . but I think that it works . . .) in the
    current UCS.
    It is not an "ACAD" solution but a "mathematical" one.

    ciao

    domenico
     
    Domenico Maria Pisano, Jul 18, 2003
    #12
  13. Devin

    Devin Guest

    You're stronger in math than I. I'll need to use the ucs and projection
    lines and entities into the current ucs. Sorry for my lack of math skill.
    I'll use what you've given me.

    Thanks,

    Devin
     
    Devin, Jul 18, 2003
    #13
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.