vla-Transformby

Discussion in 'AutoCAD' started by BillZ, Jul 15, 2004.

  1. BillZ

    BillZ Guest

    R2005

    Is there a way to transform an object using the transformby method that will rotate the object around an arbitrary axis instead of the WCS axis?
    I can't find anything in the documentation.

    (vla-Transformby object newrotation1)

    TIA

    Bill
     
    BillZ, Jul 15, 2004
    #1
  2. BillZ

    Devin Guest

    Hi Bill,

    Use the vector cross product to obtain a vector that is perpendicular to two
    given vectors. That should supply you with the 3rd point for 3pxa_matrix,
    simply supply 3pxa_matrix with the axis of rotation a-b then the vector
    cross product as c. The formula is:

    c (x,y,z) = Ay*Bz - Az*By , Az*Bx - Ax*Bz , Ax*By - Ay*Bx

    Where AB is a line from A to B defining the axis of rotation.

    The right hand rule might be off on this (ie: perhaps it's left hand) I
    didn't check and I really don't think it matters in this case, it should
    work anyway.

    HTH,

    Devin
     
    Devin, Jul 15, 2004
    #2
  3. BillZ

    BillZ Guest

    Thanks,
    I'll do some x-perimenting with this. :)

    Bill
     
    BillZ, Jul 15, 2004
    #3
  4. BillZ

    BillZ Guest

    Devin,
    Check this syntax.
    Did I get the right idea?
    Seems like I'm gettting a point that's out of the plane.
    Is the axis points in the basse plane or the rotated plane?

    (setq px (list (- (* (cadr p1)(caddr p2))(* (caddr p1)(cadr p2)))
    (- (* (caddr p1)(car p2))(* (car p1)(caddr p2)))
    (- (* (car p1)(cadr p2))(* (cadr p1)(car p2)))
    )
    )

    Thanks

    Bill
     
    BillZ, Jul 16, 2004
    #4
  5. BillZ

    Devin Guest

    BillZ,

    I'm still investigating, yea the vector cross product doesn't work on the
    plane axis very well. I'll do some research.

    Devin
     
    Devin, Jul 16, 2004
    #5
  6. BillZ

    Devin Guest

    I've got to leave. I can find a solution but I don't have the time right
    now, can it wait til monday?
     
    Devin, Jul 16, 2004
    #6
  7. BillZ

    BillZ Guest

    can it wait til monday?<<<<

    It's going to have to. :)

    I leave at 2:00 CDT.

    Thanks

    Bill
     
    BillZ, Jul 19, 2004
    #7
  8. BillZ

    BillZ Guest

    The main problem I am having is getting the x, y and z rotaion angles from the rectangle that I am trying to transform.
    Is ther a way to get these angles if I know the points of the rectangle? These rectangles are not always equal sides and the edges don't always follow the x and y axis. The formulas I have now don't always retund the right angles.
    I have yet to find the formula for the x,y shifts.

    Thanks for your patience as I want to learn and understand how to do this.

    Bill
     
    BillZ, Jul 19, 2004
    #8
  9. BillZ

    BillZ Guest

    Devin,
    I think my problem was that the points need to be expressed in the entities coordinate system. I found this post by Jon Flemming:

    (defun CrossProduct (V1 V2)
    (list (- (* (cadr V1) (caddr V2)) (* (caddr V1) (cadr V2)))
    (- (* (caddr V1) (car V2)) (* (car V1) (caddr V2)))
    (- (* (car V1) (cadr V2)) (* (cadr V1) (car V2)))
    )
    )

    (setq V1 (mapcar '- P2 P1)
    V2 (mapcar '- P3 P1)
    V3 (CrossProduct V1 V2)
    V3Magnitude (distance '(0.0 0.0 0.0) V3)
    ;; Scale to unit magnitude
    ExtrusionVector (mapcar '(lambda (x) (/ x V3Magnitude))
    V3
    )
    )

    The answer is, of course, expressed in whatever coordinate system P1
    and P2 and P3 were expressed in. Since entity extrusion vectors are
    always expressed in World Coordinate system, you need to use (trans
    ..) to transform ExtrusionVector to WCS (unless P1 and P2 and P3 were
    already in WCS).

    It works when I set the ucs to the entity.


    Bill
     
    BillZ, Jul 19, 2004
    #9
  10. BillZ

    Devin Guest

    BillZ,

    Perhaps if you explained in more detail what the procedure is that you want
    to achieve?
     
    Devin, Jul 19, 2004
    #10
  11. BillZ

    Devin Guest

    Bill,

    If you're simply trying to align the plane of a rectangle to a known plane,
    that's pretty easy and if you give me your required perameters then I can
    come up with something pretty quick.

    Devin
     
    Devin, Jul 19, 2004
    #11
  12. BillZ

    BillZ Guest

    Devin,
    My end goal is to take a 3d mesh (which consists of many rectangles) and unfold or flatten it so that it represents the 2d sheet of material that the mesh consists of.
    I know from modeling experience that these things are handled in small areas. I thought if I could read each rectangle in the mesh and derive the position of each one, I could transform each from it's position in space to the flat WCS.


    Bill
     
    BillZ, Jul 19, 2004
    #12
  13. BillZ

    Devin Guest

    Bill,

    Great! that's pretty easy to do. Just use the triangle code I gave you and
    instead of giving it all four sides (cause the 3pxa_matrix function only
    accepts three points) just give it the "hinge" side as the first two points
    then the third could probably be either of the other two points of the
    rectangle (but the code is designed for it to be the point that's to the
    right and behind). That gives you the "transform from" (ucs->wcs) matrix.

    For the "transform to" (wcs->ucs) matrix you simply give it the two points
    which are the same length apart as the "hinge" side then give it just
    another point (to the right and behind) on the same plane that's desired.

    That's it. If it's flattening then the "transform to" points will all have
    the same z value.

    HTH,

    Devin
     
    Devin, Jul 19, 2004
    #13
  14. BillZ

    BillZ Guest

    Thanks Devin,
    I'm still a little confused on creating two matrices.
    You talk about a transform-to and transform-from matrix.
    Does 3pxa_matrix.lsp figure both these matrixes internally?
    vla-transformby only uses one (I think).

    Bill
     
    BillZ, Jul 19, 2004
    #14
  15. BillZ

    Devin Guest

    It's the same process as the c:delta function, but instead of rotating a
    triangle your just rotating a rectangle. But remember, when you set up the
    first matrix it's creating a matrix that's lined up with the same plane as
    the rectangle, that in fact flattens the rectangle when it's transformed
    from that plane to the WCS.

    Next, the only thing that's left is to put that flattened rectangle where
    you want it, the second transformation is simply a placement really. You
    just specify where you want the rectangle to be. Just remember that the
    first two points given to 3pxa_matrix are the alinged edge (ie: p1 and p2 of
    the original rectangle will end up aligned with p1 and p2 of the final
    transformation.

    I'm not sure if that helps, please let me know, I'm having a little trouble
    explaining maybe. If that doesn't help then I'll put together a drawing
    that illustrates it instead.

    Let me know,

    Devin
     
    Devin, Jul 19, 2004
    #15
  16. BillZ

    BillZ Guest

    Thanks,
    Let me work on this for a while.
    If nothing else, I've learned a lot about the 3d world.
    I'll let you know if I need help.

    Bill
     
    BillZ, Jul 19, 2004
    #16
  17. BillZ

    Devin Guest

    Bill,

    I guess there's another question I should be asking you. Are all four
    points of the rectangle co-planar? If not then you will have to do
    sub-transformations for the two bi-secting triangles that make up the
    rectangle, that's pretty easy to do as well.
     
    Devin, Jul 19, 2004
    #17
  18. BillZ

    BillZ Guest

    Let me know <<<,

    Devin,
    3pxa_matrix works great! Actually better than what I imagined.
    Now I'll use this as my unfold "engine" when I run my demo.
    I guess I don't have to know everything, I just have to know people that do. :)


    Thanks again!

    Bill
     
    BillZ, Jul 20, 2004
    #18
  19. BillZ

    Devin Guest

    Bill,

    I think your efforts may be best spent learning transformations, as they can
    cover just about everything. I use it pretty much for everything here. We
    have developed our own 3d panel modeling software "plugin" for autocad using
    transformations. And so far we haven't been limited in what we can do at
    all.

    Let me know if there's anything I can do.

    Devin
     
    Devin, Jul 20, 2004
    #19
  20. BillZ

    Devin Guest

    I guess I don't have to know everything, I just have to know people that
    do. :)

    Somehow I think you'll understand it more and more as you use it! There's
    some really great tuts on transformations, just do a search for "3d
    rotation" and "transformation matrix". Here's a great tut that really
    helped me http://www.makegames.com/3drotation/

    Devin
     
    Devin, Jul 20, 2004
    #20
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.