How to trans WCS to OCS ?

Discussion in 'AutoCAD' started by ifiew, Sep 13, 2004.

  1. ifiew

    ifiew Guest

    Can someone show me the mathematical expressions about translating WCS to OCS ?
    I need calculate the value in OCS when I know the value in WCS . I use this in the C++ program :-]
    Can somebody help me ?
    Thanks,
    ifiew
     
    ifiew, Sep 13, 2004
    #1
  2. ifiew

    Douglas Barr Guest

    Somehow I don't think this is what you're after, but here it is just the
    same:

    (setq point (list 1.0 2.0 3.0))
    (trans point 0 1) ; converts it from the WCS to your current modelspace UCS
    (trans point 0 2) ; converts it from the WCS to the current viewport's UCS
    (trans point 0 3) ; converts it from the WCS to the current paperspace UCS
    -doug
     
    Douglas Barr, Sep 13, 2004
    #2
  3. ifiew

    Joe Burke Guest

    ifiew,

    That's a fun question... ;-)

    Joe Burke

    See the following posted 8/3/2003.
     
    Joe Burke, Sep 13, 2004
    #3
  4. ifiew

    Joe Burke Guest

    Hi Bill,

    That looks like John's latest version. Thanks for posting it.

    I've used it. I'm sure it works as expected transforming a point WCS to OCS.

    Joe Burke
     
    Joe Burke, Sep 13, 2004
    #4
  5. ifiew

    BillZ Guest

    You're welcome.

    I found it in my archives and shook the cobwebs off it.

    My translation testing has ceased for now since I ran into an accumlative accuracy problem in my unfold mesh tests.

    But I am sure this is the latest version.

    Bill
     
    BillZ, Sep 13, 2004
    #5
  6. ifiew

    sheldonmcc Guest

    I'm looking for the same thing (see my posting DXF Codes 10 210 Formula). Unfortunately I always see the same types of answers....in AutoLISP. Of course, this doesn't help since we are working outside of AutoCAD. I'm still waiting for some assistance on my posting.
     
    sheldonmcc, Sep 14, 2004
    #6
  7. ifiew

    Jeff Mishler Guest

    Did you happen to look at the lisp file posted by BillZ?

    If you had, you might've seen in the header that Larry & John included
    multiple references that would be beneficial to you.

    If you haven't, I'd suggest doing so.........
     
    Jeff Mishler, Sep 14, 2004
    #7
  8. ifiew

    Joe Burke Guest

    In addition to what Jeff said... you should look on the web for tutorials written by
    game programmers. Game software relies heavily on matrix and vector math. Which is
    totally independent of any lisp functions available under ACAD.

    BTW, an attitude like someone owes you an answer will almost always return zero
    results.

    Joe Burke
     
    Joe Burke, Sep 15, 2004
    #8
  9. ifiew

    ifiew Guest

    I've got it . :)
    For example:
    0
    CIRCLE
    5
    93
    100
    AcDbEntity
    8
    0
    100
    AcDbCircle
    10
    -2.895377203008716
    20
    22.18318099539349
    30
    54.07639973511205
    40
    4.513139999999999
    210
    0.1433730436417575
    220
    -0.2456260747668692
    230
    0.9587032918226155
    The center Point value (-2.895377203008716,22.18318099539349,54.07639973511205)is in OCS .
    The value in WCS is:(-0.467296,-6.54411,58.1523)
    When I know the circle center in WCS , and I want to write it in a *.dxf file , I must know the value in OCS .
    First : Calculate the OCS .
    We know the x , y , z axis in WCS is:
    Wx (1,0,0) Wy (0,1,0) Wz (0,0,1)
    The origin of the OCS and WCS is the same .
    The z axis of OCS is the value of the "210 " "220" "230"
    We always call it N , Here we are looking for the arbitrary X and Y axes to go with the normal N . They will be called Ax and Ay. N could also be called Az (the Z axis of OCS) .
    N (0.1433730436417575,-0.2456260747668692,0.9587032918226155)

    We calculate Ax first .
    if ( |Nx| < (1/64) && |Ny| < (1/64) )
    Ax = Wy × N (where “׆is the cross-product operator).
    else
    Ax = Wz × N

    Scale Ax to unit length.
    I got Ax (0.86364,0.50411,0) .

    The method of getting the Ay vector is as follows:
    Ay = N × Ax. Scale Ay to unit length.
    I got Ay (-0.483867,0.827974,0.28449422547) .

    So , the OCS matrix is
    matrixO :
    Axi Ayi Ni
    Axj Ayj Nj
    Axk Ayk Nk

    The center Point value in WCS is
    matrix1 : [x0,y0,z0]

    The value in OCS is matrix1*matrixO
    Axi Ayi Ni
    [ x0 y0 z0 ] × Axj Ayj Nj = [ x y z ]
    Axk Ayk Nk

    The result is the value in OCS ,also is the value below "10" "20" "30" in the dxf files.

    In this example:
    x0 = -0.467296
    y0 = -6.54411
    z0 = 58.1523
    and
    x = -2.895377203008716
    y = 22.18318099539349
    z = 54.07639973511205

    So the key is got the OCS matrix . :p
     
    ifiew, Sep 16, 2004
    #9
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.