Molecular Modeling Software
リビジョン | 7a7cd6e0079533f337abd5106a85b0440c906405 (tree) |
---|---|
日時 | 2010-02-18 23:37:11 |
作者 | toshinagata1964 <toshinagata1964@a2be...> |
コミッター | toshinagata1964 |
Ruby commands now handle angles in degree, rather than in radian.
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/molby/trunk@9 a2be9bc6-48de-4e38-9406-05402d4bc13c
@@ -1113,11 +1113,20 @@ MolActionPerform(Molecule *mol, MolAction *action) | ||
1113 | 1113 | needsRebuildMDArena = 1; |
1114 | 1114 | } else if (strcmp(action->name, gMolActionAddSymmetryOperation) == 0) { |
1115 | 1115 | Transform *trp; |
1116 | + Transform itr = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; | |
1116 | 1117 | trp = (Transform *)action->args[0].u.arval.ptr; |
1117 | 1118 | if (mol->nsyms == 0) { |
1118 | - Transform itr = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}; | |
1119 | - if (AssignArray(&mol->syms, &mol->nsyms, sizeof(Transform), mol->nsyms, &itr) == 0) | |
1120 | - return -1; | |
1119 | + for (n1 = 0; n1 < 12; n1++) { | |
1120 | + if (fabs((*trp)[n1] - itr[n1]) > 1e-8) | |
1121 | + break; | |
1122 | + } | |
1123 | + if (n1 < 12) { | |
1124 | + if (AssignArray(&mol->syms, &mol->nsyms, sizeof(Transform), mol->nsyms, &itr) == 0) | |
1125 | + return -1; | |
1126 | + act2 = MolActionNew(gMolActionDeleteSymmetryOperation); | |
1127 | + MolActionCallback_registerUndo(mol, act2); | |
1128 | + MolActionRelease(act2); | |
1129 | + } | |
1121 | 1130 | } |
1122 | 1131 | if (AssignArray(&mol->syms, &mol->nsyms, sizeof(Transform), mol->nsyms, trp) == 0) |
1123 | 1132 | return -1; |
@@ -1127,8 +1136,8 @@ MolActionPerform(Molecule *mol, MolAction *action) | ||
1127 | 1136 | return -1; |
1128 | 1137 | act2 = MolActionNew(gMolActionAddSymmetryOperation, &(mol->syms[mol->nsyms - 1])); |
1129 | 1138 | mol->nsyms--; |
1130 | - if (mol->nsyms == 1) | |
1131 | - mol->nsyms--; /* Remove the identity operation */ | |
1139 | + /* if (mol->nsyms == 1) | |
1140 | + mol->nsyms--; *//* Remove the identity operation */ | |
1132 | 1141 | if (mol->nsyms == 0) { |
1133 | 1142 | free(mol->syms); |
1134 | 1143 | mol->syms = NULL; |
@@ -68,7 +68,7 @@ extern const char *gMolActionXtalToCartesian; | ||
68 | 68 | * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "rotate", vec, angle); |
69 | 69 | * (Will perform 'mol.rotate(vec, angle)') |
70 | 70 | * or: |
71 | - * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "proc {|v,d| rotate(v,d*3.1415927/180)}", vec, deg) | |
71 | + * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "proc {|v,d| rotate(v,d)}", vec, deg) | |
72 | 72 | * (Will perform '(mol.instance_eval "proc {...}").call(vec, deg)') |
73 | 73 | */ |
74 | 74 | #define kMolActionPerformScript "script:s" |
@@ -7175,7 +7175,7 @@ MoleculeMeasureAngle(Molecule *mp, const Vector *vp1, const Vector *vp2, const V | ||
7175 | 7175 | w = VecLength(r1) * VecLength(r3); |
7176 | 7176 | if (w < 1e-20) |
7177 | 7177 | return NAN; |
7178 | - return acos(VecDot(r1, r3) / w) * 180.0 / 3.1415927; | |
7178 | + return acos(VecDot(r1, r3) / w) * kRad2Deg; | |
7179 | 7179 | } |
7180 | 7180 | |
7181 | 7181 | Double |
@@ -7212,7 +7212,7 @@ MoleculeMeasureDihedral(Molecule *mp, const Vector *vp1, const Vector *vp2, cons | ||
7212 | 7212 | VecScaleSelf(v1, w1); |
7213 | 7213 | VecScaleSelf(v2, w2); |
7214 | 7214 | VecScaleSelf(v3, w3); |
7215 | - return -atan2(VecDot(v3, v2), VecDot(v1, v2)) * 180.0 / 3.1415927; | |
7215 | + return -atan2(VecDot(v3, v2), VecDot(v1, v2)) * kRad2Deg; | |
7216 | 7216 | } |
7217 | 7217 | } |
7218 | 7218 |
@@ -88,9 +88,9 @@ ValueFromVector(const Vector *vp) | ||
88 | 88 | |
89 | 89 | /* |
90 | 90 | * call-seq: |
91 | - * Vector3D.new | |
92 | - * Vector3D.new(vector3d) | |
93 | - * Vector3D.new(ary) | |
91 | + * new | |
92 | + * new(Vector3D) | |
93 | + * new(Array) | |
94 | 94 | * |
95 | 95 | * Returns a new Vector3D object. In the first form, a zero vector |
96 | 96 | * is returned. In the second form, the given vector3d is duplicated. |
@@ -111,7 +111,7 @@ s_Vector3D_Initialize(int argc, VALUE *argv, VALUE self) | ||
111 | 111 | |
112 | 112 | /* |
113 | 113 | * call-seq: |
114 | - * vector3d.size -> int | |
114 | + * size -> Integer | |
115 | 115 | * |
116 | 116 | * Returns 3. This method is present only to be consistent with classes like |
117 | 117 | * Array or Vector. |
@@ -124,9 +124,9 @@ s_Vector3D_Size(VALUE self) | ||
124 | 124 | |
125 | 125 | /* |
126 | 126 | * call-seq: |
127 | - * vector3d[index] -> float | |
127 | + * self[index] -> Float | |
128 | 128 | * |
129 | - * Element Reference---Returns the element at _index_. If _index_ is | |
129 | + * Element Reference---Returns the element at the given index. If the index is | |
130 | 130 | * less than 0 or more than 2, an exception is thrown. |
131 | 131 | */ |
132 | 132 | static VALUE |
@@ -144,7 +144,7 @@ s_Vector3D_ElementAtIndex(VALUE self, VALUE val) | ||
144 | 144 | |
145 | 145 | /* |
146 | 146 | * call-seq: |
147 | - * vector3d[index] = float | |
147 | + * self[index] = val | |
148 | 148 | * |
149 | 149 | * Element Assignment---Set the element at _index_. If _index_ is |
150 | 150 | * less than 0 or more than 2, an exception is thrown. |
@@ -169,7 +169,7 @@ s_Vector3D_SetElementAtIndex(VALUE self, VALUE idx, VALUE val) | ||
169 | 169 | |
170 | 170 | /* |
171 | 171 | * call-seq: |
172 | - * vector3d == other_vector3d -> bool | |
172 | + * self == val -> bool | |
173 | 173 | * |
174 | 174 | * Equality---Two vector3ds are equal if their elements are all equal. |
175 | 175 | * Usual caution about comparison between floating point numbers should be |
@@ -188,9 +188,9 @@ s_Vector3D_IsEqual(VALUE self, VALUE val) | ||
188 | 188 | |
189 | 189 | /* |
190 | 190 | * call-seq: |
191 | - * vector3d + other_vector3d -> (new) vector3d | |
191 | + * self + val -> (new) Vector3D | |
192 | 192 | * |
193 | - * Add two vectors element by element. | |
193 | + * Add two vectors element by element. Val is converted to Vector3D. | |
194 | 194 | */ |
195 | 195 | static VALUE |
196 | 196 | s_Vector3D_Add(VALUE self, VALUE val) |
@@ -208,9 +208,9 @@ s_Vector3D_Add(VALUE self, VALUE val) | ||
208 | 208 | |
209 | 209 | /* |
210 | 210 | * call-seq: |
211 | - * vector3d - other_vector3d -> (new) vector3d | |
211 | + * self - val -> (new) Vector3D | |
212 | 212 | * |
213 | - * Subtract two vectors element by element. | |
213 | + * Subtract two vectors element by element. Val is converted to Vector3D. | |
214 | 214 | */ |
215 | 215 | static VALUE |
216 | 216 | s_Vector3D_Subtract(VALUE self, VALUE val) |
@@ -228,9 +228,11 @@ s_Vector3D_Subtract(VALUE self, VALUE val) | ||
228 | 228 | |
229 | 229 | /* |
230 | 230 | * call-seq: |
231 | - * vector3d.dot(other_vector3d) -> float | |
231 | + * self.dot(val) -> Float | |
232 | 232 | * |
233 | - * Calculate the dot (inner) product of the two vectors. See also <code>vector3d.*</code>. | |
233 | + * Calculate the dot (inner) product of the two vectors. Val is converted to Vector3D. | |
234 | + * | |
235 | + * <b>See Also:</b> Vector3D.* | |
234 | 236 | */ |
235 | 237 | static VALUE |
236 | 238 | s_Vector3D_Dot(VALUE self, VALUE val) |
@@ -243,12 +245,12 @@ s_Vector3D_Dot(VALUE self, VALUE val) | ||
243 | 245 | |
244 | 246 | /* |
245 | 247 | * call-seq: |
246 | - * vector3d * numeric -> (new) vector3d | |
247 | - * vector3d * other_vector3d -> float (the dot product) | |
248 | + * self * numeric -> (new) Vector3D | |
249 | + * self * val -> Float | |
248 | 250 | * |
249 | 251 | * In the first form, the vector is scaled by the numeric. In the second |
250 | - * form, the dot (inner) product of the two vectors are returned (equivalent to | |
251 | - * <code>vector3d.dot(other_vector3d)</code>). | |
252 | + * form, the dot (inner) product of the two vectors are returned, which is equivalent to | |
253 | + * self.dot(val). | |
252 | 254 | */ |
253 | 255 | static VALUE |
254 | 256 | s_Vector3D_Multiply(VALUE self, VALUE val) |
@@ -266,7 +268,7 @@ s_Vector3D_Multiply(VALUE self, VALUE val) | ||
266 | 268 | |
267 | 269 | /* |
268 | 270 | * call-seq: |
269 | - * vector3d / numeric -> (new) vector3d | |
271 | + * self / numeric -> (new) Vector3D | |
270 | 272 | * |
271 | 273 | * The vector is scaled by the inverse of the given numeric. |
272 | 274 | */ |
@@ -284,9 +286,9 @@ s_Vector3D_Divide(VALUE self, VALUE val) | ||
284 | 286 | |
285 | 287 | /* |
286 | 288 | * call-seq: |
287 | - * vector3d.cross(other_vector3d) -> (new) vector3d | |
289 | + * self.cross(val) -> (new) Vector3D | |
288 | 290 | * |
289 | - * Calculate the cross (outer) product of the two vectors. | |
291 | + * Calculate the cross (outer) product of the two vectors. Val is converted to Vector3D. | |
290 | 292 | */ |
291 | 293 | static VALUE |
292 | 294 | s_Vector3D_Cross(VALUE self, VALUE val) |
@@ -302,7 +304,7 @@ s_Vector3D_Cross(VALUE self, VALUE val) | ||
302 | 304 | |
303 | 305 | /* |
304 | 306 | * call-seq: |
305 | - * vector3d.-@ -> vector3d | |
307 | + * -self -> (new) Vector3D | |
306 | 308 | * |
307 | 309 | * Calculate the opposite vector. |
308 | 310 | */ |
@@ -319,10 +321,10 @@ s_Vector3D_UnaryMinus(VALUE self) | ||
319 | 321 | |
320 | 322 | /* |
321 | 323 | * call-seq: |
322 | - * vector3d.length -> float | |
324 | + * length -> Float | |
323 | 325 | * |
324 | 326 | * Calculate the Pythagorean length of the vector. |
325 | - * Note that this method is <em>not</em> an alias of <code>vector3d.size</code>. | |
327 | + * Note that this method is <em>not</em> an alias of Vector3D#size, which returns 3. | |
326 | 328 | */ |
327 | 329 | static VALUE |
328 | 330 | s_Vector3D_Length(VALUE self) |
@@ -334,7 +336,7 @@ s_Vector3D_Length(VALUE self) | ||
334 | 336 | |
335 | 337 | /* |
336 | 338 | * call-seq: |
337 | - * vector3d.length2 -> float | |
339 | + * length2 -> Float | |
338 | 340 | * |
339 | 341 | * Calculate the square of the Pythagorean length of the vector. |
340 | 342 | */ |
@@ -348,7 +350,7 @@ s_Vector3D_Length2(VALUE self) | ||
348 | 350 | |
349 | 351 | /* |
350 | 352 | * call-seq: |
351 | - * vector3d.normalize -> (new) vector3d | |
353 | + * normalize -> (new) Vector3D | |
352 | 354 | * |
353 | 355 | * Returns a unit vector with the same direction. Raises an exception when the |
354 | 356 | * vector is a zero vector. |
@@ -370,9 +372,9 @@ s_Vector3D_Normalize(VALUE self) | ||
370 | 372 | |
371 | 373 | /* |
372 | 374 | * call-seq: |
373 | - * vector3d.to_a -> Array | |
375 | + * to_a -> Array | |
374 | 376 | * |
375 | - * Returns <code>[self.x, self.y, self.z]</code>. | |
377 | + * Returns [self.x, self.y, self.z]. | |
376 | 378 | */ |
377 | 379 | static VALUE |
378 | 380 | s_Vector3D_ToArray(VALUE self) |
@@ -384,9 +386,9 @@ s_Vector3D_ToArray(VALUE self) | ||
384 | 386 | |
385 | 387 | /* |
386 | 388 | * call-seq: |
387 | - * vector3d.each {|item| block } -> vector3d (self) | |
389 | + * each {|item| ...} | |
388 | 390 | * |
389 | - * Calls <i>block</i> once for x, y, z elements, passing that element as a parameter. | |
391 | + * Calls block for x, y, z elements, passing that element as a parameter. | |
390 | 392 | */ |
391 | 393 | static VALUE |
392 | 394 | s_Vector3D_Each(VALUE self) |
@@ -401,7 +403,7 @@ s_Vector3D_Each(VALUE self) | ||
401 | 403 | |
402 | 404 | /* |
403 | 405 | * call-seq: |
404 | - * vector3d.x -> float | |
406 | + * x -> Float | |
405 | 407 | * |
406 | 408 | * Get the x element of the vector. |
407 | 409 | */ |
@@ -415,7 +417,7 @@ s_Vector3D_GetX(VALUE self) | ||
415 | 417 | |
416 | 418 | /* |
417 | 419 | * call-seq: |
418 | - * vector3d.y -> float | |
420 | + * y -> Float | |
419 | 421 | * |
420 | 422 | * Get the y element of the vector. |
421 | 423 | */ |
@@ -429,7 +431,7 @@ s_Vector3D_GetY(VALUE self) | ||
429 | 431 | |
430 | 432 | /* |
431 | 433 | * call-seq: |
432 | - * vector3d.z -> float | |
434 | + * z -> Float | |
433 | 435 | * |
434 | 436 | * Get the z element of the vector. |
435 | 437 | */ |
@@ -443,7 +445,7 @@ s_Vector3D_GetZ(VALUE self) | ||
443 | 445 | |
444 | 446 | /* |
445 | 447 | * call-seq: |
446 | - * vector3d.x = float -> float | |
448 | + * x = val | |
447 | 449 | * |
448 | 450 | * Set the x element of the vector. |
449 | 451 | */ |
@@ -458,7 +460,7 @@ s_Vector3D_SetX(VALUE self, VALUE val) | ||
458 | 460 | |
459 | 461 | /* |
460 | 462 | * call-seq: |
461 | - * vector3d.y = float -> float | |
463 | + * y = val | |
462 | 464 | * |
463 | 465 | * Set the y element of the vector. |
464 | 466 | */ |
@@ -473,7 +475,7 @@ s_Vector3D_SetY(VALUE self, VALUE val) | ||
473 | 475 | |
474 | 476 | /* |
475 | 477 | * call-seq: |
476 | - * vector3d.z = float -> float | |
478 | + * z = val | |
477 | 479 | * |
478 | 480 | * Set the z element of the vector. |
479 | 481 | */ |
@@ -488,9 +490,9 @@ s_Vector3D_SetZ(VALUE self, VALUE val) | ||
488 | 490 | |
489 | 491 | /* |
490 | 492 | * call-seq: |
491 | - * Vector3d[fx, fy, fz] -> (new) vector3d | |
493 | + * Vector3d[fx, fy, fz] -> (new) Vector3D | |
492 | 494 | * |
493 | - * Create a new vector3d object. Equivalent to <code>Vector3d.new([fx, fy, fz])</code>. | |
495 | + * Create a new vector3d object. Equivalent to Vector3D#new([fx, fy, fz]). | |
494 | 496 | */ |
495 | 497 | static VALUE |
496 | 498 | s_Vector3D_Create(VALUE klass, VALUE args) |
@@ -502,9 +504,9 @@ s_Vector3D_Create(VALUE klass, VALUE args) | ||
502 | 504 | |
503 | 505 | /* |
504 | 506 | * call-seq: |
505 | - * vector3d.inspect -> string | |
507 | + * inspect -> String | |
506 | 508 | * |
507 | - * Create a readable string like "Vector3d[fx, fy, fz]". | |
509 | + * Create a readable string like "Vector3D[fx, fy, fz]". | |
508 | 510 | */ |
509 | 511 | static VALUE |
510 | 512 | s_Vector3D_Inspect(VALUE self) |
@@ -596,9 +598,9 @@ ValueFromTransform(Transform *tp) | ||
596 | 598 | |
597 | 599 | /* |
598 | 600 | * call-seq: |
599 | - * Transform.new | |
600 | - * Transform.new(array) | |
601 | - * Transform.new(matrix) | |
601 | + * new | |
602 | + * new(array) | |
603 | + * new(matrix) | |
602 | 604 | * |
603 | 605 | * Returns a new Transform object. |
604 | 606 | * |
@@ -612,8 +614,8 @@ ValueFromTransform(Transform *tp) | ||
612 | 614 | * the translation part. All vectors in (1) are column vectors. |
613 | 615 | * |
614 | 616 | * In the third form, a new transform is built from a 3x4 matrix. The argument |
615 | - * <code>matrix</code> must respond to a method call <code>matrix[col, row]</code> | |
616 | - * where <code>row</code> is in <code>0..2</code> and <code>col</code> in <code>0..3</code>. | |
617 | + * +matrix+ must respond to a method call <tt>matrix[col, row]</tt> | |
618 | + * where <tt>row</tt> is in <tt>0..2</tt> and <tt>col</tt> in <tt>0..3</tt>. | |
617 | 619 | */ |
618 | 620 | static VALUE |
619 | 621 | s_Transform_Initialize(int argc, VALUE *argv, VALUE self) |
@@ -639,11 +641,11 @@ s_Transform_NewFromTransform(Transform *tp) | ||
639 | 641 | |
640 | 642 | /* |
641 | 643 | * call-seq: |
642 | - * Transform.from_columns(c1, c2, c3, c4) | |
644 | + * from_columns(c1, c2, c3, c4) | |
643 | 645 | * |
644 | 646 | * Returns a new Transform object built from four column vectors. The arguments |
645 | - * <code>c1..c4</code> are vectors of (at least) three-dimension. This is equivalent | |
646 | - * to <code>Transform.new([c1, c2, c3, c4])</code>. | |
647 | + * <tt>c1..c4</tt> are vectors of (at least) three-dimension. This is equivalent | |
648 | + * to <tt>Transform.new([c1, c2, c3, c4])</tt>. | |
647 | 649 | */ |
648 | 650 | static VALUE |
649 | 651 | s_Transform_NewFromColumns(VALUE klass, VALUE val) |
@@ -681,10 +683,10 @@ s_Transform_NewFromColumns(VALUE klass, VALUE val) | ||
681 | 683 | |
682 | 684 | /* |
683 | 685 | * call-seq: |
684 | - * Transform.from_rows(r1, r2, r3) | |
686 | + * from_rows(r1, r2, r3) | |
685 | 687 | * |
686 | 688 | * Returns a new Transform object built from three row vectors. The arguments |
687 | - * <code>r1, r2, r3</code> are vectors of (at least) four-dimension. | |
689 | + * <tt>r1, r2, r3</tt> are vectors of (at least) four-dimension. | |
688 | 690 | */ |
689 | 691 | static VALUE |
690 | 692 | s_Transform_NewFromRows(VALUE klass, VALUE val) |
@@ -722,7 +724,7 @@ s_Transform_NewFromRows(VALUE klass, VALUE val) | ||
722 | 724 | |
723 | 725 | /* |
724 | 726 | * call-seq: |
725 | - * transform[i, j] -> float | |
727 | + * self[i, j] -> Float | |
726 | 728 | * |
727 | 729 | * Get the element (+i+,+j+) of the transform matrix, i.e. column +i+, row +j+. |
728 | 730 | * Be careful about the order of the arguments. It follows convention of multi-dimensional arrays |
@@ -744,7 +746,7 @@ s_Transform_ElementAtIndex(VALUE self, VALUE val1, VALUE val2) | ||
744 | 746 | |
745 | 747 | /* |
746 | 748 | * call-seq: |
747 | - * transform[i, j] = float -> float | |
749 | + * self[i, j] = val | |
748 | 750 | * |
749 | 751 | * Set the element (+i+,+j+) of the transform matrix, i.e. column +i+, row +j+. |
750 | 752 | * Be careful about the order of the arguments. It follows convention of multi-dimensional arrays |
@@ -767,7 +769,7 @@ s_Transform_SetElementAtIndex(VALUE self, VALUE idx1, VALUE idx2, VALUE val) | ||
767 | 769 | |
768 | 770 | /* |
769 | 771 | * call-seq: |
770 | - * transform == other_transform -> bool | |
772 | + * self == val -> bool | |
771 | 773 | * |
772 | 774 | * Returns +true+ if and only if all the corresponding elements are equal. |
773 | 775 | * Usual caution about the comparison of floating-point numbers should be paid. |
@@ -788,7 +790,7 @@ s_Transform_IsEqual(VALUE self, VALUE val) | ||
788 | 790 | |
789 | 791 | /* |
790 | 792 | * call-seq: |
791 | - * transform + other_transform -> (new) transform | |
793 | + * self + val -> (new) Transform | |
792 | 794 | * |
793 | 795 | * Returns a new transform corresponding to the sum of the two transform matrix. |
794 | 796 | */ |
@@ -806,7 +808,7 @@ s_Transform_Add(VALUE self, VALUE val) | ||
806 | 808 | |
807 | 809 | /* |
808 | 810 | * call-seq: |
809 | - * transform - other_transform -> (new) transform | |
811 | + * self - val -> (new) Transform | |
810 | 812 | * |
811 | 813 | * Returns a new transform corresponding to the difference of the two transform matrix. |
812 | 814 | */ |
@@ -824,9 +826,9 @@ s_Transform_Subtract(VALUE self, VALUE val) | ||
824 | 826 | |
825 | 827 | /* |
826 | 828 | * call-seq: |
827 | - * transform * numeric -> (new) transform | |
828 | - * transform * vector3d -> (new) vector3d | |
829 | - * transform * other_transform -> (new) transform | |
829 | + * self * numeric -> (new) Transform | |
830 | + * self * Vector3D -> (new) Vector3D | |
831 | + * self * other_transform -> (new) Transform | |
830 | 832 | * |
831 | 833 | * Perform the matrix multiplication. In the first form, a new matrix with scaled elements |
832 | 834 | * is returned. In the second, the transformed vector is returned. In the third form, |
@@ -864,9 +866,9 @@ s_Transform_Multiply(VALUE self, VALUE val) | ||
864 | 866 | |
865 | 867 | /* |
866 | 868 | * call-seq: |
867 | - * Transform.identity -> transform | |
869 | + * identity -> Transform | |
868 | 870 | * |
869 | - * Returns an identity transform, <code>[[1,0,0], [0,1,0], [0,0,1], [0,0,0]]</code>. | |
871 | + * Returns an identity transform, <tt>[[1,0,0], [0,1,0], [0,0,1], [0,0,0]]</tt>. | |
870 | 872 | */ |
871 | 873 | static VALUE |
872 | 874 | s_Transform_Identity(VALUE klass) |
@@ -879,9 +881,9 @@ s_Transform_Identity(VALUE klass) | ||
879 | 881 | |
880 | 882 | /* |
881 | 883 | * call-seq: |
882 | - * Transform.zero -> transform | |
884 | + * zero -> Transform | |
883 | 885 | * |
884 | - * Returns a zero transform, <code>[[0,0,0], [0,0,0], [0,0,0], [0,0,0]]</code>. | |
886 | + * Returns a zero transform, <tt>[[0,0,0], [0,0,0], [0,0,0], [0,0,0]]</tt>. | |
885 | 887 | */ |
886 | 888 | static VALUE |
887 | 889 | s_Transform_Zero(VALUE klass) |
@@ -893,14 +895,14 @@ s_Transform_Zero(VALUE klass) | ||
893 | 895 | |
894 | 896 | /* |
895 | 897 | * call-seq: |
896 | - * Transform.diagonal(array) | |
897 | - * Transform.diagonal(f1, f2 = nil, f3 = nil) | |
898 | + * diagonal(Array) | |
899 | + * diagonal(f1, f2 = nil, f3 = nil) | |
898 | 900 | * |
899 | 901 | * Returns a diagonal transform (the translational componets are all zero). |
900 | - * In the first form, <code>array[0], array[1], array[2]</code> are for the | |
901 | - * x, y, z components, respectively. In the second form, <code>f1, f2, f3</code> | |
902 | - * are the x, y, z components. If <code>f3</code> is not given, the <code>f2</code> | |
903 | - * is used for the z components. If <code>f2</code> is not given, the <code>f1</code> | |
902 | + * In the first form, <tt>array[0], array[1], array[2]</tt> are for the | |
903 | + * x, y, z components, respectively. In the second form, <tt>f1, f2, f3</tt> | |
904 | + * are the x, y, z components. If <tt>f3</tt> is not given, the <tt>f2</tt> | |
905 | + * is used for the z components. If <tt>f2</tt> is not given, the <tt>f1</tt> | |
904 | 906 | * is used for the y and z components. |
905 | 907 | */ |
906 | 908 | static VALUE |
@@ -935,7 +937,7 @@ s_Transform_Diagonal(int argc, VALUE *argv, VALUE klass) | ||
935 | 937 | |
936 | 938 | /* |
937 | 939 | * call-seq: |
938 | - * transform.inverse -> (new) transform | |
940 | + * inverse -> (new) Transform | |
939 | 941 | * |
940 | 942 | * Returns the inverse transform. If the matrix is not regular, an exception is raised. |
941 | 943 | */ |
@@ -951,9 +953,9 @@ s_Transform_Inverse(VALUE self) | ||
951 | 953 | |
952 | 954 | /* |
953 | 955 | * call-seq: |
954 | - * transform / other_transform -> (new) transform | |
956 | + * self / val -> (new) Transform | |
955 | 957 | * |
956 | - * Returns transform * other_transform.invert. If other_transform is not regular, | |
958 | + * Returns self * val.invert. If val is not a regular transform, | |
957 | 959 | * an exception is raised. |
958 | 960 | */ |
959 | 961 | static VALUE |
@@ -970,7 +972,7 @@ s_Transform_Divide(VALUE self, VALUE val) | ||
970 | 972 | |
971 | 973 | /* |
972 | 974 | * call-seq: |
973 | - * transform.transpose -> (new) transform | |
975 | + * transpose -> (new) Transform | |
974 | 976 | * |
975 | 977 | * Returns a new transform in which the rotation component is transposed from the original. |
976 | 978 | */ |
@@ -985,7 +987,7 @@ s_Transform_Transpose(VALUE self) | ||
985 | 987 | |
986 | 988 | /* |
987 | 989 | * call-seq: |
988 | - * transform.determinant -> float | |
990 | + * determinant -> Float | |
989 | 991 | * |
990 | 992 | * Returns the determinant of the transform. |
991 | 993 | */ |
@@ -999,7 +1001,7 @@ s_Transform_Determinant(VALUE self) | ||
999 | 1001 | |
1000 | 1002 | /* |
1001 | 1003 | * call-seq: |
1002 | - * transform.trace -> float | |
1004 | + * trace -> Float | |
1003 | 1005 | * |
1004 | 1006 | * Returns the trace (sum of the diagonal elements) of the transform. |
1005 | 1007 | */ |
@@ -1013,7 +1015,7 @@ s_Transform_Trace(VALUE self) | ||
1013 | 1015 | |
1014 | 1016 | /* |
1015 | 1017 | * call-seq: |
1016 | - * transform.column(index) -> vector3d | |
1018 | + * column(index) -> Vector3D | |
1017 | 1019 | * |
1018 | 1020 | * Returns the index-th (0..3) column vector. |
1019 | 1021 | */ |
@@ -1034,7 +1036,7 @@ s_Transform_Column(VALUE self, VALUE val) | ||
1034 | 1036 | |
1035 | 1037 | /* |
1036 | 1038 | * call-seq: |
1037 | - * transform.eigenvalues -> [[k1, k2, k3], v1, v2, v3] | |
1039 | + * eigenvalues -> [[k1, k2, k3], v1, v2, v3] | |
1038 | 1040 | * |
1039 | 1041 | * Calculate the eigenvalues and eigenvectors. The matrix must be symmetric. |
1040 | 1042 | */ |
@@ -1053,7 +1055,7 @@ s_Transform_Eigenvalues(VALUE self) | ||
1053 | 1055 | |
1054 | 1056 | /* |
1055 | 1057 | * call-seq: |
1056 | - * Transform[*args] | |
1058 | + * Transform[*args] -> (new) Transform | |
1057 | 1059 | * |
1058 | 1060 | * Create a new transform. Equivalent to Transform.new(args). |
1059 | 1061 | */ |
@@ -1067,7 +1069,7 @@ s_Transform_Create(VALUE klass, VALUE args) | ||
1067 | 1069 | |
1068 | 1070 | /* |
1069 | 1071 | * call-seq: |
1070 | - * transform.to_a -> array | |
1072 | + * to_a -> Array | |
1071 | 1073 | * |
1072 | 1074 | * Convert a transform to an array of 12 float numbers. |
1073 | 1075 | */ |
@@ -1085,7 +1087,7 @@ s_Transform_ToArray(VALUE self) | ||
1085 | 1087 | |
1086 | 1088 | /* |
1087 | 1089 | * call-seq: |
1088 | - * transform.inspect -> string | |
1090 | + * inspect -> String | |
1089 | 1091 | * |
1090 | 1092 | * Convert a transform to a string like |
1091 | 1093 | * "Transform[[a11,a21,a31],[a12,a22,a32],[a13,a23,a33],[a14,a24,a34]]". |
@@ -1120,7 +1122,7 @@ s_Transform_Inspect(VALUE self) | ||
1120 | 1122 | |
1121 | 1123 | /* |
1122 | 1124 | * call-seq: |
1123 | - * Transform.translation(vec) | |
1125 | + * translation(vec) -> (new) Transform | |
1124 | 1126 | * |
1125 | 1127 | * Returns a transform corresponding to translation along the given vector. Equivalent |
1126 | 1128 | * to <code>Transform[[1,0,0],[0,1,0],[0,0,1],vec]</code>. |
@@ -1141,10 +1143,10 @@ s_Transform_Translation(VALUE klass, VALUE vec) | ||
1141 | 1143 | |
1142 | 1144 | /* |
1143 | 1145 | * call-seq: |
1144 | - * Transform.rotation(axis, angle, center = [0,0,0]) | |
1146 | + * rotation(axis, angle, center = [0,0,0]) -> (new) Transform | |
1145 | 1147 | * |
1146 | - * Returns a transform corresponding to the rotation along the given axis and angle. If | |
1147 | - * center is also given, that point will be the center of rotation. | |
1148 | + * Returns a transform corresponding to the rotation along the given axis and angle. | |
1149 | + * Angle is given in degree. If center is also given, that point will be the center of rotation. | |
1148 | 1150 | */ |
1149 | 1151 | static VALUE |
1150 | 1152 | s_Transform_Rotation(int argc, VALUE *argv, VALUE klass) |
@@ -1159,7 +1161,7 @@ s_Transform_Rotation(int argc, VALUE *argv, VALUE klass) | ||
1159 | 1161 | cv.x = cv.y = cv.z = 0.0; |
1160 | 1162 | else |
1161 | 1163 | VectorFromValue(center, &cv); |
1162 | - ang = NUM2DBL(rb_Float(angle)); | |
1164 | + ang = NUM2DBL(rb_Float(angle)) * kDeg2Rad; | |
1163 | 1165 | if (TransformForRotation(tr, &av, ang, &cv)) |
1164 | 1166 | rb_raise(rb_eMolbyError, "rotation axis cannot be a zero vector"); |
1165 | 1167 | return ValueFromTransform(&tr); |
@@ -1167,7 +1169,7 @@ s_Transform_Rotation(int argc, VALUE *argv, VALUE klass) | ||
1167 | 1169 | |
1168 | 1170 | /* |
1169 | 1171 | * call-seq: |
1170 | - * Transform.reflection(axis, center = [0,0,0]) | |
1172 | + * reflection(axis, center = [0,0,0]) -> (new)Transform | |
1171 | 1173 | * |
1172 | 1174 | * Returns a transform corresponding to the reflection along the given axis. If |
1173 | 1175 | * center is also given, that point will be fixed. |
@@ -1191,7 +1193,7 @@ s_Transform_Reflection(int argc, VALUE *argv, VALUE klass) | ||
1191 | 1193 | |
1192 | 1194 | /* |
1193 | 1195 | * call-seq: |
1194 | - * Transform.inversion(center = [0,0,0]) | |
1196 | + * inversion(center = [0,0,0]) -> (new) Transform | |
1195 | 1197 | * |
1196 | 1198 | * Returns a transform corresponding to the inversion along the given point. |
1197 | 1199 | */ |
@@ -1262,6 +1264,17 @@ s_IntGroup_Initialize_i(VALUE val, VALUE ig1) | ||
1262 | 1264 | return Qnil; |
1263 | 1265 | } |
1264 | 1266 | |
1267 | +/* | |
1268 | + * call-seq: | |
1269 | + * new(arg1, arg2,...) | |
1270 | + * new(arg1, arg2,...) {|i| ...} | |
1271 | + * | |
1272 | + * Create a new integer group. If no arguments are given, an empty group is returned. | |
1273 | + * The arguments are either IntGroup, Range, Enumerable, or Numeric. In either case, | |
1274 | + * the non-negative integers included in the arguments are added to the result. | |
1275 | + * If a block is given, the block is called with the each integer in the given arguments, | |
1276 | + * and the integer group consisting with the returned integers is returned. | |
1277 | + */ | |
1265 | 1278 | static VALUE |
1266 | 1279 | s_IntGroup_Initialize(int argc, VALUE *argv, VALUE self) |
1267 | 1280 | { |
@@ -1298,6 +1311,12 @@ s_IntGroup_Initialize(int argc, VALUE *argv, VALUE self) | ||
1298 | 1311 | return Qnil; |
1299 | 1312 | } |
1300 | 1313 | |
1314 | +/* | |
1315 | + * call-seq: | |
1316 | + * clear -> self | |
1317 | + * | |
1318 | + * Discard all integers included in self. | |
1319 | + */ | |
1301 | 1320 | static VALUE |
1302 | 1321 | s_IntGroup_Clear(VALUE self) |
1303 | 1322 | { |
@@ -1307,6 +1326,12 @@ s_IntGroup_Clear(VALUE self) | ||
1307 | 1326 | return self; |
1308 | 1327 | } |
1309 | 1328 | |
1329 | +/* | |
1330 | + * call-seq: | |
1331 | + * dup(IntGroup) -> (new) IntGroup | |
1332 | + * | |
1333 | + * (Deep) copy the given IntGroup. | |
1334 | + */ | |
1310 | 1335 | static VALUE |
1311 | 1336 | s_IntGroup_InitializeCopy(VALUE self, VALUE val) |
1312 | 1337 | { |
@@ -1319,6 +1344,13 @@ s_IntGroup_InitializeCopy(VALUE self, VALUE val) | ||
1319 | 1344 | return self; |
1320 | 1345 | } |
1321 | 1346 | |
1347 | +/* | |
1348 | + * call-seq: | |
1349 | + * length -> Integer | |
1350 | + * size -> Integer | |
1351 | + * | |
1352 | + * Returns the number of integers included in self. | |
1353 | + */ | |
1322 | 1354 | static VALUE |
1323 | 1355 | s_IntGroup_Length(VALUE self) |
1324 | 1356 | { |
@@ -1327,6 +1359,13 @@ s_IntGroup_Length(VALUE self) | ||
1327 | 1359 | return INT2NUM(IntGroupGetCount(ig)); |
1328 | 1360 | } |
1329 | 1361 | |
1362 | +/* | |
1363 | + * call-seq: | |
1364 | + * member?(val) -> bool | |
1365 | + * include?(val) -> bool | |
1366 | + * | |
1367 | + * Check whether the val is included in self. | |
1368 | + */ | |
1330 | 1369 | static VALUE |
1331 | 1370 | s_IntGroup_MemberP(VALUE self, VALUE val) |
1332 | 1371 | { |
@@ -1336,6 +1375,12 @@ s_IntGroup_MemberP(VALUE self, VALUE val) | ||
1336 | 1375 | return (IntGroupLookup(ig, n, NULL) ? Qtrue : Qfalse); |
1337 | 1376 | } |
1338 | 1377 | |
1378 | +/* | |
1379 | + * call-seq: | |
1380 | + * self[index] -> Integer or nil | |
1381 | + * | |
1382 | + * Get the index-th point in self. If the index is out of range, nil is returned. | |
1383 | + */ | |
1339 | 1384 | static VALUE |
1340 | 1385 | s_IntGroup_ElementAtIndex(VALUE self, VALUE val) |
1341 | 1386 | { |
@@ -1347,6 +1392,12 @@ s_IntGroup_ElementAtIndex(VALUE self, VALUE val) | ||
1347 | 1392 | return (n >= 0 ? INT2NUM(n) : Qnil); |
1348 | 1393 | } |
1349 | 1394 | |
1395 | +/* | |
1396 | + * call-seq: | |
1397 | + * each {|i| ...} | |
1398 | + * | |
1399 | + * Call the block with each integer in self. | |
1400 | + */ | |
1350 | 1401 | static VALUE |
1351 | 1402 | s_IntGroup_Each(VALUE self) |
1352 | 1403 | { |
@@ -1362,6 +1413,12 @@ s_IntGroup_Each(VALUE self) | ||
1362 | 1413 | return self; |
1363 | 1414 | } |
1364 | 1415 | |
1416 | +/* | |
1417 | + * call-seq: | |
1418 | + * add(IntGroup) -> self | |
1419 | + * | |
1420 | + * Add the points in the given group. | |
1421 | + */ | |
1365 | 1422 | static VALUE |
1366 | 1423 | s_IntGroup_Add(VALUE self, VALUE val) |
1367 | 1424 | { |
@@ -1382,6 +1439,12 @@ s_IntGroup_Add(VALUE self, VALUE val) | ||
1382 | 1439 | return self; |
1383 | 1440 | } |
1384 | 1441 | |
1442 | +/* | |
1443 | + * call-seq: | |
1444 | + * delete(IntGroup) -> self | |
1445 | + * | |
1446 | + * Remove the points in the given group. | |
1447 | + */ | |
1385 | 1448 | static VALUE |
1386 | 1449 | s_IntGroup_Delete(VALUE self, VALUE val) |
1387 | 1450 | { |
@@ -1415,42 +1478,100 @@ s_IntGroup_Binary(VALUE self, VALUE val, int (*func)(const IntGroup *, const Int | ||
1415 | 1478 | return retval; |
1416 | 1479 | } |
1417 | 1480 | |
1481 | +/* | |
1482 | + * call-seq: | |
1483 | + * union(val) -> (new)IntGroup | |
1484 | + * self + val -> (new)IntGroup | |
1485 | + * self | val -> (new)IntGroup | |
1486 | + * | |
1487 | + * Returns a union group. | |
1488 | + */ | |
1418 | 1489 | static VALUE |
1419 | 1490 | s_IntGroup_Union(VALUE self, VALUE val) |
1420 | 1491 | { |
1421 | 1492 | return s_IntGroup_Binary(self, val, IntGroupUnion); |
1422 | 1493 | } |
1423 | 1494 | |
1495 | +/* | |
1496 | + * call-seq: | |
1497 | + * intersection(val) -> (new)IntGroup | |
1498 | + * self & val -> (new)IntGroup | |
1499 | + * | |
1500 | + * Returns an intersection group. | |
1501 | + */ | |
1424 | 1502 | static VALUE |
1425 | 1503 | s_IntGroup_Intersection(VALUE self, VALUE val) |
1426 | 1504 | { |
1427 | 1505 | return s_IntGroup_Binary(self, val, IntGroupIntersect); |
1428 | 1506 | } |
1429 | 1507 | |
1508 | +/* | |
1509 | + * call-seq: | |
1510 | + * difference(val) -> (new)IntGroup | |
1511 | + * self - val -> (new)IntGroup | |
1512 | + * | |
1513 | + * Returns a difference group. | |
1514 | + */ | |
1430 | 1515 | static VALUE |
1431 | 1516 | s_IntGroup_Difference(VALUE self, VALUE val) |
1432 | 1517 | { |
1433 | 1518 | return s_IntGroup_Binary(self, val, IntGroupDifference); |
1434 | 1519 | } |
1435 | 1520 | |
1521 | +/* | |
1522 | + * call-seq: | |
1523 | + * sym_difference(val) -> (new)IntGroup | |
1524 | + * self ^ val -> (new)IntGroup | |
1525 | + * | |
1526 | + * Returns a symmetric-difference group (i.e. a group containing elements that are included | |
1527 | + * in either self or val but not both). | |
1528 | + */ | |
1436 | 1529 | static VALUE |
1437 | 1530 | s_IntGroup_SymDifference(VALUE self, VALUE val) |
1438 | 1531 | { |
1439 | 1532 | return s_IntGroup_Binary(self, val, IntGroupXor); |
1440 | 1533 | } |
1441 | 1534 | |
1535 | +/* | |
1536 | + * call-seq: | |
1537 | + * convolute(val) -> (new)IntGroup | |
1538 | + * | |
1539 | + * For each element n in self, get the n-th point in val, and return the result as a new group. | |
1540 | + * If n is out of range, then that point is ignored. | |
1541 | + * | |
1542 | + * <b>See Also:</b> IntGroup#deconvolute. If all points in self are within the range of val, then | |
1543 | + * an equation <tt>self.convolute(val).deconvolute(val) == self</tt> holds. | |
1544 | + */ | |
1442 | 1545 | static VALUE |
1443 | 1546 | s_IntGroup_Convolute(VALUE self, VALUE val) |
1444 | 1547 | { |
1445 | 1548 | return s_IntGroup_Binary(self, val, IntGroupConvolute); |
1446 | 1549 | } |
1447 | 1550 | |
1551 | +/* | |
1552 | + * call-seq: | |
1553 | + * deconvolute(val) -> (new)IntGroup | |
1554 | + * | |
1555 | + * For each element n in self, find the point n in val, and return the found indices as a new group. | |
1556 | + * If n is not found in val, then that point is ignored. | |
1557 | + * | |
1558 | + * <b>See Also:</b> IntGroup#convolute. If all points in self are found in val, then | |
1559 | + * an equation <tt>self.deconvolute(val).convolute(val) == self</tt> holds. | |
1560 | + */ | |
1448 | 1561 | static VALUE |
1449 | 1562 | s_IntGroup_Deconvolute(VALUE self, VALUE val) |
1450 | 1563 | { |
1451 | 1564 | return s_IntGroup_Binary(self, val, IntGroupDeconvolute); |
1452 | 1565 | } |
1453 | 1566 | |
1567 | +/* | |
1568 | + * call-seq: | |
1569 | + * range_at(val) -> Range | |
1570 | + * | |
1571 | + * Split self into consecutive chunks of integers, and return the val-th chunk as a Range. | |
1572 | + * This method is relatively efficient, because it directly uses the internal representation | |
1573 | + * of IntGroup. | |
1574 | + */ | |
1454 | 1575 | static VALUE |
1455 | 1576 | s_IntGroup_RangeAt(VALUE self, VALUE val) |
1456 | 1577 | { |
@@ -1465,6 +1586,7 @@ s_IntGroup_RangeAt(VALUE self, VALUE val) | ||
1465 | 1586 | return rb_funcall(rb_cRange, rb_intern("new"), 2, INT2NUM(sp), INT2NUM(ep)); |
1466 | 1587 | } |
1467 | 1588 | |
1589 | +/* | |
1468 | 1590 | static VALUE |
1469 | 1591 | s_IntGroup_Merge(VALUE self, VALUE val) |
1470 | 1592 | { |
@@ -1498,7 +1620,15 @@ s_IntGroup_Subtract(VALUE self, VALUE val) | ||
1498 | 1620 | IntGroupRelease(ig2); |
1499 | 1621 | return self; |
1500 | 1622 | } |
1623 | +*/ | |
1501 | 1624 | |
1625 | +/* | |
1626 | + * call-seq: | |
1627 | + * offset(val) -> self | |
1628 | + * | |
1629 | + * Move all points by an integer value. A negative val is allowed, but it | |
1630 | + * must be no smaller than -(self[0]), otherwise an exception is thrown. | |
1631 | + */ | |
1502 | 1632 | static VALUE |
1503 | 1633 | s_IntGroup_Offset(VALUE self, VALUE ofs) |
1504 | 1634 | { |
@@ -1525,6 +1655,12 @@ s_IntGroup_Create(int argc, VALUE *argv, VALUE klass) | ||
1525 | 1655 | return val; |
1526 | 1656 | } |
1527 | 1657 | |
1658 | +/* | |
1659 | + * call-seq: | |
1660 | + * inspect -> String | |
1661 | + * | |
1662 | + * Create a String in the form "IntGroup[...]". | |
1663 | + */ | |
1528 | 1664 | static VALUE |
1529 | 1665 | s_IntGroup_Inspect(VALUE self) |
1530 | 1666 | { |
@@ -1644,8 +1780,8 @@ Init_MolbyTypes(void) | ||
1644 | 1780 | rb_define_alias(rb_cIntGroup, "&", "intersection"); |
1645 | 1781 | rb_define_alias(rb_cIntGroup, "^", "sym_difference"); |
1646 | 1782 | rb_define_method(rb_cIntGroup, "range_at", s_IntGroup_RangeAt, 1); |
1647 | - rb_define_method(rb_cIntGroup, "merge", s_IntGroup_Merge, -1); | |
1648 | - rb_define_method(rb_cIntGroup, "subtract", s_IntGroup_Subtract, -1); | |
1783 | +/* rb_define_method(rb_cIntGroup, "merge", s_IntGroup_Merge, -1); | |
1784 | + rb_define_method(rb_cIntGroup, "subtract", s_IntGroup_Subtract, -1); */ | |
1649 | 1785 | rb_define_method(rb_cIntGroup, "inspect", s_IntGroup_Inspect, 0); |
1650 | 1786 | rb_define_alias(rb_cIntGroup, "to_s", "inspect"); |
1651 | 1787 | rb_define_singleton_method(rb_cIntGroup, "[]", s_IntGroup_Create, -1); |