Skip to content

Instantly share code, notes, and snippets.

@rcfox
Created August 10, 2010 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcfox/516995 to your computer and use it in GitHub Desktop.
Save rcfox/516995 to your computer and use it in GitHub Desktop.
use v6;
use Math::Matrix;
my @theta = 0,0;
my @d = 3,1;
my @a = 2,2;
my @alpha = 0,0.7;
my $T01 = Math::Matrix.new(data =>
(
[{cos(@theta[0])}, {-sin(@theta[0])*cos(@alpha[0])}, {sin(@theta[0])*sin(@alpha[0])} , {@a[0]*cos(@theta[0])}],
[{sin(@theta[0])}, {cos(@theta[0])*cos(@alpha[0])} , {-cos(@theta[0])*sin(@alpha[0])}, {@a[0]*sin(@theta[0])}],
[ 0 , {sin(@alpha[0])} , {cos(@alpha[0])} , @d[0] ],
[ 0 , 0 , 0 , 1 ],
));
my $T12 = Math::Matrix.new(data =>
(
[{cos(@theta[1])}, {-sin(@theta[1])*cos(@alpha[1])}, {sin(@theta[1])*sin(@alpha[1])} , {@a[1]*cos(@theta[1])}],
[{sin(@theta[1])}, {cos(@theta[1])*cos(@alpha[1])} , {-cos(@theta[1])*sin(@alpha[1])}, {@a[1]*sin(@theta[1])}],
[ 0 , {sin(@alpha[1])} , {cos(@alpha[1])} , @d[1] ],
[ 0 , 0 , 0 , 1 ],
));
my $T = $T01 * $T12;
loop (@theta[0] = 0; @theta[0] < pi/2; @theta[0] += 0.1)
{
say $T;
}
1 0 0 4
0 0.764842187284488 -0.644217687237691 0
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.995004165278026 -0.0763568087522437 0.0643144527812564 3.9800166611121
0.0998334166468282 0.761021162128422 -0.640999282147279 0.399333666587313
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.980066577841242 -0.15195068551164 0.127986296809854 3.92026631136497
0.198669330795061 0.749596265080519 -0.631376224115843 0.794677323180245
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.955336489125606 -0.226026321249623 0.190379344067373 3.82134595650242
0.29552020666134 0.730681649935512 -0.615444663558273 1.18208082664536
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.921060994002885 -0.297843576700048 0.250870183850014 3.68424397601154
0.389418342308651 0.704466305275592 -0.593363783361387 1.5576733692346
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.877582561890373 -0.366684877586083 0.308854411682284 3.51033024756149
0.479425538604203 0.671212166158958 -0.565354208381144 1.91770215441681
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.825335614909678 -0.431862384385182 0.363752668326719 3.30134245963871
0.564642473395035 0.631251496951307 -0.531695801032011 2.25856989358014
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.764842187284488 -0.49272486499423 0.415016428549879 3.05936874913795
0.644217687237691 0.584983571450121 -0.49272486499423 2.57687074895076
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.696706709347165 -0.548664201625441 0.462133481805161 2.78682683738866
0.717356090899523 0.532870683472864 -0.448830784978613 2.86942436359809
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.621609968270664 -0.599121466918283 0.504633050071265 2.48643987308266
0.783326909627483 0.475433527769976 -0.400452136123222 3.13330763850993
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.54030230586814 -0.643592508556904 0.542090491710565 2.16120922347256
0.841470984807897 0.413245997415041 -0.348072301895565 3.36588393923159
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.453596121425577 -0.681632986593423 0.574131544347986 1.81438448570231
0.891207360061435 0.346929449654899 -0.292214644284772 3.56482944024574
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.362357754476674 -0.712862813145809 0.600436064376938 1.44943101790669
0.932039085967226 0.277146497513435 -0.233437274541606 3.72815634386891
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.267498828624587 -0.736969950110359 0.62074122572841 1.06999531449835
0.963558185417193 0.204594389181268 -0.172327476715323 3.85423274166877
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.169967142900241 -0.753713526943282 0.634844145942173 0.679868571600964
0.98544972998846 0.129998041342316 -0.109495839705591 3.94179891995384
0 0.644217687237691 0.764842187284488 4
0 0 0 1
0.0707372016677029 -0.762926247359556 0.642603913301256 0.282948806670812
0.997494986604054 0.0541027960459099 -0.0455701564600337 3.98997994641622
0 0.644217687237691 0.764842187284488 4
0 0 0 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment