• R/O
  • HTTP
  • SSH
  • HTTPS

Molby: コミット

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

変更サマリ

差分

--- a/MolLib/MolAction.c
+++ b/MolLib/MolAction.c
@@ -1113,11 +1113,20 @@ MolActionPerform(Molecule *mol, MolAction *action)
11131113 needsRebuildMDArena = 1;
11141114 } else if (strcmp(action->name, gMolActionAddSymmetryOperation) == 0) {
11151115 Transform *trp;
1116+ Transform itr = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0};
11161117 trp = (Transform *)action->args[0].u.arval.ptr;
11171118 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+ }
11211130 }
11221131 if (AssignArray(&mol->syms, &mol->nsyms, sizeof(Transform), mol->nsyms, trp) == 0)
11231132 return -1;
@@ -1127,8 +1136,8 @@ MolActionPerform(Molecule *mol, MolAction *action)
11271136 return -1;
11281137 act2 = MolActionNew(gMolActionAddSymmetryOperation, &(mol->syms[mol->nsyms - 1]));
11291138 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 */
11321141 if (mol->nsyms == 0) {
11331142 free(mol->syms);
11341143 mol->syms = NULL;
--- a/MolLib/MolAction.h
+++ b/MolLib/MolAction.h
@@ -68,7 +68,7 @@ extern const char *gMolActionXtalToCartesian;
6868 * MolActionCreateAndPerform(mol, SCRIPT_ACTION("vd"), "rotate", vec, angle);
6969 * (Will perform 'mol.rotate(vec, angle)')
7070 * 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)
7272 * (Will perform '(mol.instance_eval "proc {...}").call(vec, deg)')
7373 */
7474 #define kMolActionPerformScript "script:s"
--- a/MolLib/Molecule.c
+++ b/MolLib/Molecule.c
@@ -7175,7 +7175,7 @@ MoleculeMeasureAngle(Molecule *mp, const Vector *vp1, const Vector *vp2, const V
71757175 w = VecLength(r1) * VecLength(r3);
71767176 if (w < 1e-20)
71777177 return NAN;
7178- return acos(VecDot(r1, r3) / w) * 180.0 / 3.1415927;
7178+ return acos(VecDot(r1, r3) / w) * kRad2Deg;
71797179 }
71807180
71817181 Double
@@ -7212,7 +7212,7 @@ MoleculeMeasureDihedral(Molecule *mp, const Vector *vp1, const Vector *vp2, cons
72127212 VecScaleSelf(v1, w1);
72137213 VecScaleSelf(v2, w2);
72147214 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;
72167216 }
72177217 }
72187218
--- a/MolLib/Ruby_bind/ruby_types.c
+++ b/MolLib/Ruby_bind/ruby_types.c
@@ -88,9 +88,9 @@ ValueFromVector(const Vector *vp)
8888
8989 /*
9090 * call-seq:
91- * Vector3D.new
92- * Vector3D.new(vector3d)
93- * Vector3D.new(ary)
91+ * new
92+ * new(Vector3D)
93+ * new(Array)
9494 *
9595 * Returns a new Vector3D object. In the first form, a zero vector
9696 * is returned. In the second form, the given vector3d is duplicated.
@@ -111,7 +111,7 @@ s_Vector3D_Initialize(int argc, VALUE *argv, VALUE self)
111111
112112 /*
113113 * call-seq:
114- * vector3d.size -> int
114+ * size -> Integer
115115 *
116116 * Returns 3. This method is present only to be consistent with classes like
117117 * Array or Vector.
@@ -124,9 +124,9 @@ s_Vector3D_Size(VALUE self)
124124
125125 /*
126126 * call-seq:
127- * vector3d[index] -> float
127+ * self[index] -> Float
128128 *
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
130130 * less than 0 or more than 2, an exception is thrown.
131131 */
132132 static VALUE
@@ -144,7 +144,7 @@ s_Vector3D_ElementAtIndex(VALUE self, VALUE val)
144144
145145 /*
146146 * call-seq:
147- * vector3d[index] = float
147+ * self[index] = val
148148 *
149149 * Element Assignment---Set the element at _index_. If _index_ is
150150 * less than 0 or more than 2, an exception is thrown.
@@ -169,7 +169,7 @@ s_Vector3D_SetElementAtIndex(VALUE self, VALUE idx, VALUE val)
169169
170170 /*
171171 * call-seq:
172- * vector3d == other_vector3d -> bool
172+ * self == val -> bool
173173 *
174174 * Equality---Two vector3ds are equal if their elements are all equal.
175175 * Usual caution about comparison between floating point numbers should be
@@ -188,9 +188,9 @@ s_Vector3D_IsEqual(VALUE self, VALUE val)
188188
189189 /*
190190 * call-seq:
191- * vector3d + other_vector3d -> (new) vector3d
191+ * self + val -> (new) Vector3D
192192 *
193- * Add two vectors element by element.
193+ * Add two vectors element by element. Val is converted to Vector3D.
194194 */
195195 static VALUE
196196 s_Vector3D_Add(VALUE self, VALUE val)
@@ -208,9 +208,9 @@ s_Vector3D_Add(VALUE self, VALUE val)
208208
209209 /*
210210 * call-seq:
211- * vector3d - other_vector3d -> (new) vector3d
211+ * self - val -> (new) Vector3D
212212 *
213- * Subtract two vectors element by element.
213+ * Subtract two vectors element by element. Val is converted to Vector3D.
214214 */
215215 static VALUE
216216 s_Vector3D_Subtract(VALUE self, VALUE val)
@@ -228,9 +228,11 @@ s_Vector3D_Subtract(VALUE self, VALUE val)
228228
229229 /*
230230 * call-seq:
231- * vector3d.dot(other_vector3d) -> float
231+ * self.dot(val) -> Float
232232 *
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.*
234236 */
235237 static VALUE
236238 s_Vector3D_Dot(VALUE self, VALUE val)
@@ -243,12 +245,12 @@ s_Vector3D_Dot(VALUE self, VALUE val)
243245
244246 /*
245247 * call-seq:
246- * vector3d * numeric -> (new) vector3d
247- * vector3d * other_vector3d -> float (the dot product)
248+ * self * numeric -> (new) Vector3D
249+ * self * val -> Float
248250 *
249251 * 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).
252254 */
253255 static VALUE
254256 s_Vector3D_Multiply(VALUE self, VALUE val)
@@ -266,7 +268,7 @@ s_Vector3D_Multiply(VALUE self, VALUE val)
266268
267269 /*
268270 * call-seq:
269- * vector3d / numeric -> (new) vector3d
271+ * self / numeric -> (new) Vector3D
270272 *
271273 * The vector is scaled by the inverse of the given numeric.
272274 */
@@ -284,9 +286,9 @@ s_Vector3D_Divide(VALUE self, VALUE val)
284286
285287 /*
286288 * call-seq:
287- * vector3d.cross(other_vector3d) -> (new) vector3d
289+ * self.cross(val) -> (new) Vector3D
288290 *
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.
290292 */
291293 static VALUE
292294 s_Vector3D_Cross(VALUE self, VALUE val)
@@ -302,7 +304,7 @@ s_Vector3D_Cross(VALUE self, VALUE val)
302304
303305 /*
304306 * call-seq:
305- * vector3d.-@ -> vector3d
307+ * -self -> (new) Vector3D
306308 *
307309 * Calculate the opposite vector.
308310 */
@@ -319,10 +321,10 @@ s_Vector3D_UnaryMinus(VALUE self)
319321
320322 /*
321323 * call-seq:
322- * vector3d.length -> float
324+ * length -> Float
323325 *
324326 * 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.
326328 */
327329 static VALUE
328330 s_Vector3D_Length(VALUE self)
@@ -334,7 +336,7 @@ s_Vector3D_Length(VALUE self)
334336
335337 /*
336338 * call-seq:
337- * vector3d.length2 -> float
339+ * length2 -> Float
338340 *
339341 * Calculate the square of the Pythagorean length of the vector.
340342 */
@@ -348,7 +350,7 @@ s_Vector3D_Length2(VALUE self)
348350
349351 /*
350352 * call-seq:
351- * vector3d.normalize -> (new) vector3d
353+ * normalize -> (new) Vector3D
352354 *
353355 * Returns a unit vector with the same direction. Raises an exception when the
354356 * vector is a zero vector.
@@ -370,9 +372,9 @@ s_Vector3D_Normalize(VALUE self)
370372
371373 /*
372374 * call-seq:
373- * vector3d.to_a -> Array
375+ * to_a -> Array
374376 *
375- * Returns <code>[self.x, self.y, self.z]</code>.
377+ * Returns [self.x, self.y, self.z].
376378 */
377379 static VALUE
378380 s_Vector3D_ToArray(VALUE self)
@@ -384,9 +386,9 @@ s_Vector3D_ToArray(VALUE self)
384386
385387 /*
386388 * call-seq:
387- * vector3d.each {|item| block } -> vector3d (self)
389+ * each {|item| ...}
388390 *
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.
390392 */
391393 static VALUE
392394 s_Vector3D_Each(VALUE self)
@@ -401,7 +403,7 @@ s_Vector3D_Each(VALUE self)
401403
402404 /*
403405 * call-seq:
404- * vector3d.x -> float
406+ * x -> Float
405407 *
406408 * Get the x element of the vector.
407409 */
@@ -415,7 +417,7 @@ s_Vector3D_GetX(VALUE self)
415417
416418 /*
417419 * call-seq:
418- * vector3d.y -> float
420+ * y -> Float
419421 *
420422 * Get the y element of the vector.
421423 */
@@ -429,7 +431,7 @@ s_Vector3D_GetY(VALUE self)
429431
430432 /*
431433 * call-seq:
432- * vector3d.z -> float
434+ * z -> Float
433435 *
434436 * Get the z element of the vector.
435437 */
@@ -443,7 +445,7 @@ s_Vector3D_GetZ(VALUE self)
443445
444446 /*
445447 * call-seq:
446- * vector3d.x = float -> float
448+ * x = val
447449 *
448450 * Set the x element of the vector.
449451 */
@@ -458,7 +460,7 @@ s_Vector3D_SetX(VALUE self, VALUE val)
458460
459461 /*
460462 * call-seq:
461- * vector3d.y = float -> float
463+ * y = val
462464 *
463465 * Set the y element of the vector.
464466 */
@@ -473,7 +475,7 @@ s_Vector3D_SetY(VALUE self, VALUE val)
473475
474476 /*
475477 * call-seq:
476- * vector3d.z = float -> float
478+ * z = val
477479 *
478480 * Set the z element of the vector.
479481 */
@@ -488,9 +490,9 @@ s_Vector3D_SetZ(VALUE self, VALUE val)
488490
489491 /*
490492 * call-seq:
491- * Vector3d[fx, fy, fz] -> (new) vector3d
493+ * Vector3d[fx, fy, fz] -> (new) Vector3D
492494 *
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]).
494496 */
495497 static VALUE
496498 s_Vector3D_Create(VALUE klass, VALUE args)
@@ -502,9 +504,9 @@ s_Vector3D_Create(VALUE klass, VALUE args)
502504
503505 /*
504506 * call-seq:
505- * vector3d.inspect -> string
507+ * inspect -> String
506508 *
507- * Create a readable string like "Vector3d[fx, fy, fz]".
509+ * Create a readable string like "Vector3D[fx, fy, fz]".
508510 */
509511 static VALUE
510512 s_Vector3D_Inspect(VALUE self)
@@ -596,9 +598,9 @@ ValueFromTransform(Transform *tp)
596598
597599 /*
598600 * call-seq:
599- * Transform.new
600- * Transform.new(array)
601- * Transform.new(matrix)
601+ * new
602+ * new(array)
603+ * new(matrix)
602604 *
603605 * Returns a new Transform object.
604606 *
@@ -612,8 +614,8 @@ ValueFromTransform(Transform *tp)
612614 * the translation part. All vectors in (1) are column vectors.
613615 *
614616 * 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>.
617619 */
618620 static VALUE
619621 s_Transform_Initialize(int argc, VALUE *argv, VALUE self)
@@ -639,11 +641,11 @@ s_Transform_NewFromTransform(Transform *tp)
639641
640642 /*
641643 * call-seq:
642- * Transform.from_columns(c1, c2, c3, c4)
644+ * from_columns(c1, c2, c3, c4)
643645 *
644646 * 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>.
647649 */
648650 static VALUE
649651 s_Transform_NewFromColumns(VALUE klass, VALUE val)
@@ -681,10 +683,10 @@ s_Transform_NewFromColumns(VALUE klass, VALUE val)
681683
682684 /*
683685 * call-seq:
684- * Transform.from_rows(r1, r2, r3)
686+ * from_rows(r1, r2, r3)
685687 *
686688 * 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.
688690 */
689691 static VALUE
690692 s_Transform_NewFromRows(VALUE klass, VALUE val)
@@ -722,7 +724,7 @@ s_Transform_NewFromRows(VALUE klass, VALUE val)
722724
723725 /*
724726 * call-seq:
725- * transform[i, j] -> float
727+ * self[i, j] -> Float
726728 *
727729 * Get the element (+i+,+j+) of the transform matrix, i.e. column +i+, row +j+.
728730 * 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)
744746
745747 /*
746748 * call-seq:
747- * transform[i, j] = float -> float
749+ * self[i, j] = val
748750 *
749751 * Set the element (+i+,+j+) of the transform matrix, i.e. column +i+, row +j+.
750752 * 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)
767769
768770 /*
769771 * call-seq:
770- * transform == other_transform -> bool
772+ * self == val -> bool
771773 *
772774 * Returns +true+ if and only if all the corresponding elements are equal.
773775 * Usual caution about the comparison of floating-point numbers should be paid.
@@ -788,7 +790,7 @@ s_Transform_IsEqual(VALUE self, VALUE val)
788790
789791 /*
790792 * call-seq:
791- * transform + other_transform -> (new) transform
793+ * self + val -> (new) Transform
792794 *
793795 * Returns a new transform corresponding to the sum of the two transform matrix.
794796 */
@@ -806,7 +808,7 @@ s_Transform_Add(VALUE self, VALUE val)
806808
807809 /*
808810 * call-seq:
809- * transform - other_transform -> (new) transform
811+ * self - val -> (new) Transform
810812 *
811813 * Returns a new transform corresponding to the difference of the two transform matrix.
812814 */
@@ -824,9 +826,9 @@ s_Transform_Subtract(VALUE self, VALUE val)
824826
825827 /*
826828 * 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
830832 *
831833 * Perform the matrix multiplication. In the first form, a new matrix with scaled elements
832834 * 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)
864866
865867 /*
866868 * call-seq:
867- * Transform.identity -> transform
869+ * identity -> Transform
868870 *
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>.
870872 */
871873 static VALUE
872874 s_Transform_Identity(VALUE klass)
@@ -879,9 +881,9 @@ s_Transform_Identity(VALUE klass)
879881
880882 /*
881883 * call-seq:
882- * Transform.zero -> transform
884+ * zero -> Transform
883885 *
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>.
885887 */
886888 static VALUE
887889 s_Transform_Zero(VALUE klass)
@@ -893,14 +895,14 @@ s_Transform_Zero(VALUE klass)
893895
894896 /*
895897 * call-seq:
896- * Transform.diagonal(array)
897- * Transform.diagonal(f1, f2 = nil, f3 = nil)
898+ * diagonal(Array)
899+ * diagonal(f1, f2 = nil, f3 = nil)
898900 *
899901 * 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>
904906 * is used for the y and z components.
905907 */
906908 static VALUE
@@ -935,7 +937,7 @@ s_Transform_Diagonal(int argc, VALUE *argv, VALUE klass)
935937
936938 /*
937939 * call-seq:
938- * transform.inverse -> (new) transform
940+ * inverse -> (new) Transform
939941 *
940942 * Returns the inverse transform. If the matrix is not regular, an exception is raised.
941943 */
@@ -951,9 +953,9 @@ s_Transform_Inverse(VALUE self)
951953
952954 /*
953955 * call-seq:
954- * transform / other_transform -> (new) transform
956+ * self / val -> (new) Transform
955957 *
956- * Returns transform * other_transform.invert. If other_transform is not regular,
958+ * Returns self * val.invert. If val is not a regular transform,
957959 * an exception is raised.
958960 */
959961 static VALUE
@@ -970,7 +972,7 @@ s_Transform_Divide(VALUE self, VALUE val)
970972
971973 /*
972974 * call-seq:
973- * transform.transpose -> (new) transform
975+ * transpose -> (new) Transform
974976 *
975977 * Returns a new transform in which the rotation component is transposed from the original.
976978 */
@@ -985,7 +987,7 @@ s_Transform_Transpose(VALUE self)
985987
986988 /*
987989 * call-seq:
988- * transform.determinant -> float
990+ * determinant -> Float
989991 *
990992 * Returns the determinant of the transform.
991993 */
@@ -999,7 +1001,7 @@ s_Transform_Determinant(VALUE self)
9991001
10001002 /*
10011003 * call-seq:
1002- * transform.trace -> float
1004+ * trace -> Float
10031005 *
10041006 * Returns the trace (sum of the diagonal elements) of the transform.
10051007 */
@@ -1013,7 +1015,7 @@ s_Transform_Trace(VALUE self)
10131015
10141016 /*
10151017 * call-seq:
1016- * transform.column(index) -> vector3d
1018+ * column(index) -> Vector3D
10171019 *
10181020 * Returns the index-th (0..3) column vector.
10191021 */
@@ -1034,7 +1036,7 @@ s_Transform_Column(VALUE self, VALUE val)
10341036
10351037 /*
10361038 * call-seq:
1037- * transform.eigenvalues -> [[k1, k2, k3], v1, v2, v3]
1039+ * eigenvalues -> [[k1, k2, k3], v1, v2, v3]
10381040 *
10391041 * Calculate the eigenvalues and eigenvectors. The matrix must be symmetric.
10401042 */
@@ -1053,7 +1055,7 @@ s_Transform_Eigenvalues(VALUE self)
10531055
10541056 /*
10551057 * call-seq:
1056- * Transform[*args]
1058+ * Transform[*args] -> (new) Transform
10571059 *
10581060 * Create a new transform. Equivalent to Transform.new(args).
10591061 */
@@ -1067,7 +1069,7 @@ s_Transform_Create(VALUE klass, VALUE args)
10671069
10681070 /*
10691071 * call-seq:
1070- * transform.to_a -> array
1072+ * to_a -> Array
10711073 *
10721074 * Convert a transform to an array of 12 float numbers.
10731075 */
@@ -1085,7 +1087,7 @@ s_Transform_ToArray(VALUE self)
10851087
10861088 /*
10871089 * call-seq:
1088- * transform.inspect -> string
1090+ * inspect -> String
10891091 *
10901092 * Convert a transform to a string like
10911093 * "Transform[[a11,a21,a31],[a12,a22,a32],[a13,a23,a33],[a14,a24,a34]]".
@@ -1120,7 +1122,7 @@ s_Transform_Inspect(VALUE self)
11201122
11211123 /*
11221124 * call-seq:
1123- * Transform.translation(vec)
1125+ * translation(vec) -> (new) Transform
11241126 *
11251127 * Returns a transform corresponding to translation along the given vector. Equivalent
11261128 * 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)
11411143
11421144 /*
11431145 * call-seq:
1144- * Transform.rotation(axis, angle, center = [0,0,0])
1146+ * rotation(axis, angle, center = [0,0,0]) -> (new) Transform
11451147 *
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.
11481150 */
11491151 static VALUE
11501152 s_Transform_Rotation(int argc, VALUE *argv, VALUE klass)
@@ -1159,7 +1161,7 @@ s_Transform_Rotation(int argc, VALUE *argv, VALUE klass)
11591161 cv.x = cv.y = cv.z = 0.0;
11601162 else
11611163 VectorFromValue(center, &cv);
1162- ang = NUM2DBL(rb_Float(angle));
1164+ ang = NUM2DBL(rb_Float(angle)) * kDeg2Rad;
11631165 if (TransformForRotation(tr, &av, ang, &cv))
11641166 rb_raise(rb_eMolbyError, "rotation axis cannot be a zero vector");
11651167 return ValueFromTransform(&tr);
@@ -1167,7 +1169,7 @@ s_Transform_Rotation(int argc, VALUE *argv, VALUE klass)
11671169
11681170 /*
11691171 * call-seq:
1170- * Transform.reflection(axis, center = [0,0,0])
1172+ * reflection(axis, center = [0,0,0]) -> (new)Transform
11711173 *
11721174 * Returns a transform corresponding to the reflection along the given axis. If
11731175 * center is also given, that point will be fixed.
@@ -1191,7 +1193,7 @@ s_Transform_Reflection(int argc, VALUE *argv, VALUE klass)
11911193
11921194 /*
11931195 * call-seq:
1194- * Transform.inversion(center = [0,0,0])
1196+ * inversion(center = [0,0,0]) -> (new) Transform
11951197 *
11961198 * Returns a transform corresponding to the inversion along the given point.
11971199 */
@@ -1262,6 +1264,17 @@ s_IntGroup_Initialize_i(VALUE val, VALUE ig1)
12621264 return Qnil;
12631265 }
12641266
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+ */
12651278 static VALUE
12661279 s_IntGroup_Initialize(int argc, VALUE *argv, VALUE self)
12671280 {
@@ -1298,6 +1311,12 @@ s_IntGroup_Initialize(int argc, VALUE *argv, VALUE self)
12981311 return Qnil;
12991312 }
13001313
1314+/*
1315+ * call-seq:
1316+ * clear -> self
1317+ *
1318+ * Discard all integers included in self.
1319+ */
13011320 static VALUE
13021321 s_IntGroup_Clear(VALUE self)
13031322 {
@@ -1307,6 +1326,12 @@ s_IntGroup_Clear(VALUE self)
13071326 return self;
13081327 }
13091328
1329+/*
1330+ * call-seq:
1331+ * dup(IntGroup) -> (new) IntGroup
1332+ *
1333+ * (Deep) copy the given IntGroup.
1334+ */
13101335 static VALUE
13111336 s_IntGroup_InitializeCopy(VALUE self, VALUE val)
13121337 {
@@ -1319,6 +1344,13 @@ s_IntGroup_InitializeCopy(VALUE self, VALUE val)
13191344 return self;
13201345 }
13211346
1347+/*
1348+ * call-seq:
1349+ * length -> Integer
1350+ * size -> Integer
1351+ *
1352+ * Returns the number of integers included in self.
1353+ */
13221354 static VALUE
13231355 s_IntGroup_Length(VALUE self)
13241356 {
@@ -1327,6 +1359,13 @@ s_IntGroup_Length(VALUE self)
13271359 return INT2NUM(IntGroupGetCount(ig));
13281360 }
13291361
1362+/*
1363+ * call-seq:
1364+ * member?(val) -> bool
1365+ * include?(val) -> bool
1366+ *
1367+ * Check whether the val is included in self.
1368+ */
13301369 static VALUE
13311370 s_IntGroup_MemberP(VALUE self, VALUE val)
13321371 {
@@ -1336,6 +1375,12 @@ s_IntGroup_MemberP(VALUE self, VALUE val)
13361375 return (IntGroupLookup(ig, n, NULL) ? Qtrue : Qfalse);
13371376 }
13381377
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+ */
13391384 static VALUE
13401385 s_IntGroup_ElementAtIndex(VALUE self, VALUE val)
13411386 {
@@ -1347,6 +1392,12 @@ s_IntGroup_ElementAtIndex(VALUE self, VALUE val)
13471392 return (n >= 0 ? INT2NUM(n) : Qnil);
13481393 }
13491394
1395+/*
1396+ * call-seq:
1397+ * each {|i| ...}
1398+ *
1399+ * Call the block with each integer in self.
1400+ */
13501401 static VALUE
13511402 s_IntGroup_Each(VALUE self)
13521403 {
@@ -1362,6 +1413,12 @@ s_IntGroup_Each(VALUE self)
13621413 return self;
13631414 }
13641415
1416+/*
1417+ * call-seq:
1418+ * add(IntGroup) -> self
1419+ *
1420+ * Add the points in the given group.
1421+ */
13651422 static VALUE
13661423 s_IntGroup_Add(VALUE self, VALUE val)
13671424 {
@@ -1382,6 +1439,12 @@ s_IntGroup_Add(VALUE self, VALUE val)
13821439 return self;
13831440 }
13841441
1442+/*
1443+ * call-seq:
1444+ * delete(IntGroup) -> self
1445+ *
1446+ * Remove the points in the given group.
1447+ */
13851448 static VALUE
13861449 s_IntGroup_Delete(VALUE self, VALUE val)
13871450 {
@@ -1415,42 +1478,100 @@ s_IntGroup_Binary(VALUE self, VALUE val, int (*func)(const IntGroup *, const Int
14151478 return retval;
14161479 }
14171480
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+ */
14181489 static VALUE
14191490 s_IntGroup_Union(VALUE self, VALUE val)
14201491 {
14211492 return s_IntGroup_Binary(self, val, IntGroupUnion);
14221493 }
14231494
1495+/*
1496+ * call-seq:
1497+ * intersection(val) -> (new)IntGroup
1498+ * self & val -> (new)IntGroup
1499+ *
1500+ * Returns an intersection group.
1501+ */
14241502 static VALUE
14251503 s_IntGroup_Intersection(VALUE self, VALUE val)
14261504 {
14271505 return s_IntGroup_Binary(self, val, IntGroupIntersect);
14281506 }
14291507
1508+/*
1509+ * call-seq:
1510+ * difference(val) -> (new)IntGroup
1511+ * self - val -> (new)IntGroup
1512+ *
1513+ * Returns a difference group.
1514+ */
14301515 static VALUE
14311516 s_IntGroup_Difference(VALUE self, VALUE val)
14321517 {
14331518 return s_IntGroup_Binary(self, val, IntGroupDifference);
14341519 }
14351520
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+ */
14361529 static VALUE
14371530 s_IntGroup_SymDifference(VALUE self, VALUE val)
14381531 {
14391532 return s_IntGroup_Binary(self, val, IntGroupXor);
14401533 }
14411534
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+ */
14421545 static VALUE
14431546 s_IntGroup_Convolute(VALUE self, VALUE val)
14441547 {
14451548 return s_IntGroup_Binary(self, val, IntGroupConvolute);
14461549 }
14471550
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+ */
14481561 static VALUE
14491562 s_IntGroup_Deconvolute(VALUE self, VALUE val)
14501563 {
14511564 return s_IntGroup_Binary(self, val, IntGroupDeconvolute);
14521565 }
14531566
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+ */
14541575 static VALUE
14551576 s_IntGroup_RangeAt(VALUE self, VALUE val)
14561577 {
@@ -1465,6 +1586,7 @@ s_IntGroup_RangeAt(VALUE self, VALUE val)
14651586 return rb_funcall(rb_cRange, rb_intern("new"), 2, INT2NUM(sp), INT2NUM(ep));
14661587 }
14671588
1589+/*
14681590 static VALUE
14691591 s_IntGroup_Merge(VALUE self, VALUE val)
14701592 {
@@ -1498,7 +1620,15 @@ s_IntGroup_Subtract(VALUE self, VALUE val)
14981620 IntGroupRelease(ig2);
14991621 return self;
15001622 }
1623+*/
15011624
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+ */
15021632 static VALUE
15031633 s_IntGroup_Offset(VALUE self, VALUE ofs)
15041634 {
@@ -1525,6 +1655,12 @@ s_IntGroup_Create(int argc, VALUE *argv, VALUE klass)
15251655 return val;
15261656 }
15271657
1658+/*
1659+ * call-seq:
1660+ * inspect -> String
1661+ *
1662+ * Create a String in the form "IntGroup[...]".
1663+ */
15281664 static VALUE
15291665 s_IntGroup_Inspect(VALUE self)
15301666 {
@@ -1644,8 +1780,8 @@ Init_MolbyTypes(void)
16441780 rb_define_alias(rb_cIntGroup, "&", "intersection");
16451781 rb_define_alias(rb_cIntGroup, "^", "sym_difference");
16461782 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); */
16491785 rb_define_method(rb_cIntGroup, "inspect", s_IntGroup_Inspect, 0);
16501786 rb_define_alias(rb_cIntGroup, "to_s", "inspect");
16511787 rb_define_singleton_method(rb_cIntGroup, "[]", s_IntGroup_Create, -1);
旧リポジトリブラウザで表示