Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^10: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?

by fraizerangus (Sexton)
on Jul 02, 2012 at 16:46 UTC ( [id://979462]=note: print w/replies, xml ) Need Help??


in reply to Re^9: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
in thread Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?

Ah yes sorry I was speaking with my biology hat on again A is angstroms, which the data is already calculated in, I just use the Elucidian distance calculation to do the check :)
  • Comment on Re^10: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?

Replies are listed 'Best First'.
Re^11: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?
by BrowserUk (Patriarch) on Jul 02, 2012 at 17:49 UTC
    A is angstroms, which the data is already calculated in,

    Interesting. If I set the limit calculation to 4, I get no collisions between those datasets at all. I have to increase it to 13 before I get any collisions at all.

    Which might mean my code is wrong. Or that the datasets are you provided have no collisions at that limit?

    Also, I'm not particularly impressed with your unit vector calculation. After the transform is applied to the line datapoints, they should all lie on the Z-axis. They almost do, but the discrepancies are larger than I would like to see:

    [ [0, 0, "-1.64339316511165"], ["-0.0575455472996209", "-0.0224071887914015", "-4.64348473502688"], ["-0.114768843254732", "-0.0450882573775804", "-7.64267013501932"], ["-0.172842568057038", "-0.066807562033258", "-10.641262423793"], ["-0.230388115356658", "-0.0892147508246577", "-13.6413539937082"], ["-0.28761141131177", "-0.111895819410838", "-16.6405393937007"], ["-0.344834707266879", "-0.134576887997017", "-19.6397247936931"], ["-0.403322450352862", "-0.156984076788417", "-22.6394813007782"], ["-0.460545746307973", "-0.179665145374598", "-25.6386667007706"], ["-0.517677275323917", "-0.201384450030274", "-28.6375940523744"], ["-0.575222822623537", "-0.223791638821677", "-31.6376856222897"], ["-0.633388314365008", "-0.246472707407854", "-34.6365359594519"], ["-0.69093386166463", "-0.268879896199255", "-37.6366275293672"], ["-0.748157157619741", "-0.291560964785434", "-40.6358129293596"], ["-0.806230882422045", "-0.313280269441112", "-43.6344052181333"], ["-0.863776429721667", "-0.335687458232513", "-46.6344967880485"], ["-0.92099972567678", "-0.35836852681869", "-49.633682188041"], ["-0.978223021631888", "-0.381049595404871", "-52.6328675880334"], ]

    Close, but no cigar :) Perhaps it is just the low accuracy of the unit vector values you supplied.

    When I derive the tranform from a unit vector calculated to greater precision, and then apply the transform back to the points the unit vector was derived from, I get much more satisfying results, Ie, given list line:

    x x x x x 1 0 0 x x x x x 2 1 1 x x x x x 3 2 2 x x x x x 4 3 3 x x x x x 5 4 4 x x x x x 6 5 5 x x x x x 7 6 6 x x x x x 8 7 7 x x x x x 9 8 8 x x x x x 10 9 9 x x x x x 11 10 10

    I calculate the unit vector as (0.57735026918962576450914878050196, 0.57735026918962576450914878050196, 0.57735026918962576450914878050196 )

    Deriving the transform from that, and applying it to the points above, I get:

    [ [ 0, 0, "0.5773502691 +89626"], ["-5.55111512312578e-017", 0, "2.3094010767 +585" ], ["-2.77555756156289e-016", 0, "4.0414518843 +2738" ], [" 1.66533453693773e-016", 0, "5.7735026918 +9626" ], ["-7.21644966006352e-016", 0, "7.5055534994 +6513" ], ["-7.21644966006352e-016", 0, "9.2376043070 +3401" ], [" 1.66533453693773e-016", "4.44089209850063e-016", "10.9696551146 +029" ], ["-7.21644966006352e-016", "-4.44089209850063e-016", "12.7017059221 +718" ], ["-7.21644966006352e-016", "-4.44089209850063e-016", "14.4337567297 +406" ], ["-1.60982338570648e-015", "4.44089209850063e-016", "16.1658075373 +095" ], ["-1.60982338570648e-015", "4.44089209850063e-016", "17.8978583448 +784" ], ]

    Which is a much more satisfying alignment between the axis of rotation and the z-axis The difference between made-up data and real-world measurements I guess :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?

      I must confess I just took took the difference between the first and last Cartesian co-ordinates and multiplied it by the inverse of the distance? as below? I just assumed it would do?
      $Xl1 = -3.901 $Yl1 = 9.352 $Zl1 = -1.557 $Xl2 = -47.430 $Yl2 = -2.993 $Zl2 = -17.639 $Axx = $Xl1 - $Xl2; $Axy = $Yl1 - $Yl2; $Axz = $Zl1 - $Zl2; $Vform = V($Axx,$Axy,$Axz); $vector = sqrt($Axx**2 + $Axy**2 + $Axz**2); $Unitvector = 1/$vector * $Vform;

      best wishes Dan

        Okay. That explains a lot. The coordinates you've used above for the last point:

        $Xl2 = -47.430 $Yl2 = -2.993 $Zl2 = -17.639

        are different from those you supplied in Re^4: Polar Co-Ordinates: Rotating a 3D cartesian point around a fixed axis?:

        ATOM CA GLY A 101 -50.317 -4.262 -17.720

        When I do the same thing using the line data from that post:

        #! perl -slw use strict; use constant { X=>0, Y=>1, Z=>2, W=>3 }; my @first = ( -3.901, ,9.352, ,-1.557 ); my @last = ( -50.317, -4.262, -17.720 ); my @v = ( $last[X] - $first[X], $last[Y] - $first[Y], $last[Z] - $first[Z], ); my $l = sqrt( $v[X]**2 + $v[Y]**2 + $v[Z]**2 ); my @unitVec = map $_ / $l, @v; print "@unitVec"; __END__ [20:14:31.75] C:\test>unitVec.pl -0.910112639703537 -0.266939707793087 -0.316919824963984

        And put those in place of your supplied unit vector:0.906 0.258 0.335 and re-run the transforms, I get much better correspondence between rotation axis and the Z-axis:

        [20:10:08.00] C:\test>979082 -LIM4A=15 [ [0, 0, "1.54737342767147"], [ "1.06484137623042e-005", "-1.2776161742778e-005", "4.54810050618 +484"], [ "0.000325405667775502", "0.000255895356081837", "7.54791747205 +851"], ["-0.000219093060060072", "-0.000435009701289957", "10.54715057839 +94" ], ["-0.000208444646297323", "-0.000447785863032735", "13.54787765691 +28" ], [ "0.000106312607715875", "-0.000179114345206344", "16.54769462278 +65" ], [ "0.000421069861728629", "8.95571726164945e-005", "19.54751158866 +01" ], ["-0.000516734055701296", "7.67810108754929e-005", "22.54792174734 +85" ], ["-0.000201976801687653", "0.000345452528700108", "25.54773871322 +22" ], [ "0.00020197680166989", "-0.000345452528671686", "28.54728873938 +81" ], [ "0.000212625215433082", "-0.000358228690412687", "31.54801581790 +14" ], ["-0.000421069861747281", "-8.95571725898492e-005", "34.54751586395 +01" ], ["-0.000410421447985865", "-0.000102333334330851", "37.54824294246 +35" ], ["-9.56641939722225e-005", "0.000166338183491987", "40.54805990833 +72" ], ["-0.000640162921804244", "-0.000524566873879806", "43.54729301467 +81" ], ["-0.000629514508044604", "-0.000537343035622584", "46.54802009319 +14" ], ["-0.000314757254034514", "-0.000268671517799746", "49.54783705906 +51" ], ["-1.73194791841524e-014", "2.66453525910038e-014", "52.54765402493 +88" ], ]

        That's much more satisfying :)

        And the affect that has on the collision results are small, but I think significant:

        [20:19:34.18] C:\test>979082 -LIM4A=15 R: 0 [ -18.731, -0.135, -11.272 ] [ 6.260, 52° +] S:259 angle: -58.482° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R: 5 [ -18.388, -2.409, -9.308 ] [ 7.454, 75° +] S:259 angle: -35.177° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R: 6 [ -18.784, -3.016, -7.671 ] [ 7.681, 89° +] S:259 angle: -21.699° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R: 7 [ -17.107, -3.128, -6.966 ] [ 8.259, 90° +] S:245 angle: -27.682° [ -5.672, 3.533, 0.140 ] [ 5.742, 118° +] S:256 angle: -23.655° [ -5.562, 1.600, 0.400 ] [ 7.610, 114° +] S:257 angle: -22.479° [ -5.970, 0.493, 0.400 ] [ 8.569, 112° +] S:258 angle: -22.287° [ -5.825, 0.591, 0.400 ] [ 8.500, 112° +] S:259 angle: -20.441° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] S:254 angle: -20.325° [ -4.738, 1.093, 0.400 ] [ 8.200, 110° +] S:255 angle: -20.193° [ -4.814, 0.899, 0.400 ] [ 8.368, 110° +] S: 7 angle: -12.398° [ -3.823, -2.789, 0.030 ] [ 11.951, 102° +] R:140 [ -18.510, -10.387, -3.385 ] [ 15.488, 107° +] S:259 angle: -3.661° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +] R:141 [ -17.411, -10.096, -2.922 ] [ 15.540, 107° +] S:256 angle: -6.629° [ -5.562, 1.600, 0.400 ] [ 7.610, 114° +] S:257 angle: -5.453° [ -5.970, 0.493, 0.400 ] [ 8.569, 112° +] S:258 angle: -5.261° [ -5.825, 0.591, 0.400 ] [ 8.500, 112° +] S:259 angle: -3.414° [ -6.126, -0.957, 0.400 ] [ 9.888, 110° +]

        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        The start of some sanity?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://979462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-19 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found