Syntactic Confectionery Delight PerlMonks

### Comment on

 Need Help??
Hi Monks I'm writing a Perl program to rotate some Cartesian co-ordinates around an axis (acting as a pivot) but the new cartesian co-ordinates are way out, (* is dot product and x cross product). Its broken down into 2 subroutines, can anyone give any pointers or tell me where I'm going wrong please?! many thanks in advance x
```
sub Axis {

#2 sets of cartesian XYZ co-ordinates on the axis
(\$Xl1, \$Yl1, \$Zl1, \$Xl2, \$Yl2, \$Zl2) = @_;

\$Axx = \$Xl1 - \$Xl2;
\$Axy = \$Yl1 - \$Yl2;
\$Axz = \$Zl1 - \$Zl2;

\$Vform = V(\$Axx,\$Axy,\$Axz);

\$eq = sqrt(\$Axx**2 + \$Axy**2 + \$Axz**2);

\$Unitvector = 1/\$eq * \$Vform;

return(\$Vform, \$Unitvector);

}

```
sub rotator {

(*xcord, *ycord, *zcord, *TotalnumberofCoords, \$lineUnitvector, \$Xline
+coord, \$Ylinecoord, \$Zlinecoord) = @_;

\$angle = 9.4;
\$translation = 0.4;

\$coefl1 = 1-cos(\$angle);
\$coefl2 = sin(\$angle);

(\$LUVx, \$LUVy, \$LUVz) = &VectorBreakdown(\$lineUnitvector);

for (my \$i = 0; \$i < @TotalnumberofCoords; \$i++) {

\$Xco[\$i] = \$xcord[\$i] - \$Xlinecoord;
\$Yco[\$i] = \$ycord[\$i] - \$Ylinecoord;
\$Zco[\$i] = \$zcord[\$i] - \$Zlinecoord;

\$Vector[\$i] = V(\$Xco[\$i], \$Yco[\$i], \$Zco[\$i]);

\$scal[\$i] = \$lineUnitvector * \$Vector[\$i];

\$f[\$i] = \$scal[\$i] * (\$lineUnitvector - \$Vector[\$i]);

\$f[\$i] = \$coefl1 * \$f[\$i];

\$s[\$i] = \$lineUnitvector x \$Vector[\$i];

\$s[\$i] = \$coefl2 * \$s[\$i];

(\$fx[\$i], \$fy[\$i], \$fz[\$i]) = &VectorBreakdown(\$f[\$i]);

(\$sx[\$i], \$sy[\$i], \$sz[\$i]) = &VectorBreakdown(\$s[\$i]);

\$xo[\$i] = \$xcord[\$i] + \$fx[\$i] + \$sx[\$i] + (\$transl * \$LUVx);

\$yo[\$i] = \$ycord[\$i] + \$fy[\$i] + \$sy[\$i] + (\$transl * \$LUVy);

\$zo[\$i] = \$zcord[\$i] + \$fz[\$i] + \$sz[\$i] + (\$transl * \$LUVz);

\$xo[\$i] = sprintf("%.3f", \$xo[\$i]);

\$yo[\$i] = sprintf("%.3f", \$yo[\$i]);

\$zo[\$i] = sprintf("%.3f", \$zo[\$i]);

}

return(\@xo, \@yo, \@zo);

}

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [Discipulus]: found translate only good from or possibly to english.. in any other case i use double way translation

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2018-06-19 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should cpanminus be part of the standard Perl release?

Results (111 votes). Check out past polls.

Notices?