<li><a href="molby_rb/Dialog.html">Dialog</a></li>
<li><a href="molby_rb/DialogItem.html">DialogItem</a></li>
<li><a href="molby_rb/IntGroup.html">IntGroup</a></li>
+<li><a href="molby_rb/LAMatrix.html">LAMatrix</a></li>
<li><a href="molby_rb/MDArena.html">MDArena</a></li>
<li><a href="molby_rb/MolEnumerable.html">MolEnumerable</a></li>
<li><a href="molby_rb/Molecule.html">Molecule</a></li>
<li><a href="molby_rb/Dialog.html">Dialog</a></li>
<li><a href="molby_rb/DialogItem.html">DialogItem</a></li>
<li><a href="molby_rb/IntGroup.html">IntGroup</a></li>
+<li><a href="molby_rb/LAMatrix.html">LAMatrix</a></li>
<li><a href="molby_rb/MDArena.html">MDArena</a></li>
<li><a href="molby_rb/MolEnumerable.html">MolEnumerable</a></li>
<li><a href="molby_rb/Molecule.html">Molecule</a></li>
</div>
<div class="method-description">
<p>
-Create a new graphic object. Kind: a symbol representing the kind of the graphic. :line, :poly, :cylinder, :cone, :ellipsoid. Color: an array of 3 (rgb) or 4 (rgba) floating numbers. Points: an array of <a href="Vector3D.html">Vector3D</a>s.
-</p>
+Create a new graphic object. Kind: a symbol representing the kind of the graphic. :line, :poly, :cylinder, :cone, :ellipsoid. Color: an array of 3 (rgb) or 4 (rgba) floating numbers. Points: an array of <a href="Vector3D.html">Vector3D</a>s or Floats (depending on the graphic type). The arguments points = [p1, p2, ..., pn] and fill have the following meanings for each kind of the graphic.
+</p>
+<ul>
+<li><b>line</b>: Points correspond to a set of lines (p1, p2), (p2, p3), ..., (p(n-1), pn). Fill has no meaning.</li>
+<li><b>poly</b>: Points correspond to a set of connected triangles (p1, p2, p3), (p1, p3, p4), ..., (p1, p(n-1), pn). Fill has no meaning.</li>
+<li><b>cylinder</b>: p1 = center of the bottom face, p2 = center of the top face, p3 (number) = radius. If fill is true, both faces are drawn. Otherwise, only the side surface is drawn.</li>
+<li><b>cone</b>: p1 = center of the bottom face, p2 = top point, p3 (number) = radius. If fill is true, the bottom face is drawn. Otherwise, only the side surface is drawn.</li>
+<li><b>ellipsoid</b>: Two argument types. (1) p1 = center, p2 (number) = radius. (2) p1 = center, p2, p3, p4 = main axis of the ellipsoid (not necessarily orthogonal each other). Fill has no meaning.</li>
+</ul>
<p>
Returns the index of the newly created graphic.
</p>
<div id="method-M000371" class="method-detail">
<a name="M000371"></a>
<div class="method-heading">
+<span class="method-name">Vector3d[vx] → (new) Vector3D<br />
<span class="method-name">Vector3d[fx, fy, fz] → (new) Vector3D<br />
</span>
</div>
<div class="method-description">
<p>
-Create a new vector3d object. Equivalent to <a href="#M000347">Vector3D#new</a>([fx, fy, fz]).
+Create a new vector3d object. The first form is equivalent to <a href="#M000347">Vector3D#new</a>(vx), and the second form is equivalent to <a href="#M000347">Vector3D#new</a>([fx, fy, fz]).
</p>
</div>
</div>
<a name="M000347"></a>
<div class="method-heading">
<span class="method-name">new → (new) Vector3D<br />
-new(Vector3D) → (new) Vector3D<br />
+new(<a href="Vector3D.html">Vector3D</a>) → (new) Vector3D<br />
+new(<a href="LAMatrix.html">LAMatrix</a>) → (new) Vector3D<br />
new([fx, fy, fz]) → (new) Vector3D<br />
</span>
</div>
<div class="method-description">
<p>
-Returns a new <a href="Vector3D.html">Vector3D</a> object. In the first form, a zero vector is returned. In the second form, the given vector3d is duplicated. In the third form, a vector [fx, fy, fz] is returned.
+Returns a new <a href="Vector3D.html">Vector3D</a> object. In the first form, a zero vector is returned. In the second form, the given vector3d is duplicated. In the third form, a row vector or a column vector (with dimension 3 or larger) is converted to a vector3d. In the fourth form, a vector [fx, fy, fz] is returned.
</p>
</div>
</div>
</div>
</body>
-</html>
\ No newline at end of file
+</html>
vp->y = mp->data[1];
vp->z = mp->data[2];
}
+ } else if (rb_obj_is_kind_of(val, rb_cNumeric)) {
+ /* Vector3D[1] is rejected; this is desirable because Integer implements
+ the index method ([]), which could cause confusion. */
+ rb_raise(rb_eMolbyError, "single number cannot be converted to a Vector3D");
} else {
static ID mname = 0;
if (mname == 0)
/*
* call-seq:
+ * Vector3d[vx] -> (new) Vector3D.
* Vector3d[fx, fy, fz] -> (new) Vector3D
*
- * Create a new vector3d object. Equivalent to Vector3D#new([fx, fy, fz]).
+ * Create a new vector3d object. The first form is equivalent to Vector3D#new(vx), and
+ * the second form is equivalent to Vector3D#new([fx, fy, fz]).
*/
static VALUE
s_Vector3D_Create(VALUE klass, VALUE args)
{
VALUE val = s_Vector3D_Alloc(klass);
- s_Vector3D_Initialize(1, &args, val);
+ if (RARRAY_LEN(args) == 1)
+ s_Vector3D_Initialize(RARRAY_LEN(args), RARRAY_PTR(args), val);
+ else s_Vector3D_Initialize(1, &args, val);
return val;
}
}
array_format_error:
rb_raise(rb_eMolbyError, "wrong array format; must be an array of either (1) four 3D column vectors or (2) 12 numerics");
+ } else if (rb_obj_is_kind_of(val, rb_cNumeric)) {
+ /* Transform[1] is rejected; this is desirable because Integer implements
+ the index method ([]), which could cause confusion. */
+ rb_raise(rb_eMolbyError, "single number cannot be converted to a Transform");
} else {
static ID index_mid = 0, row_size_mid, column_size_mid;
if (index_mid == 0) {
* Transform[*args] -> (new) Transform
*
* Create a new transform. Equivalent to Transform.new(args).
+ * If only one argument is given that is not a number, then Transform.new(args[0])
+ * is called instead of Transform.new(args).
*/
static VALUE
s_Transform_Create(VALUE klass, VALUE args)
{
VALUE val = s_Transform_Alloc(klass);
- s_Transform_Initialize(1, &args, val);
+ if (RARRAY_LEN(args) == 1 && !rb_obj_is_kind_of(RARRAY_PTR(args)[0], rb_cNumeric))
+ s_Transform_Initialize(RARRAY_LEN(args), RARRAY_PTR(args), val);
+ else
+ s_Transform_Initialize(1, &args, val);
return val;
}
/*
* call-seq:
+ * column_size -> LAMatrix
+ *
+ * Returns the column size.
+ */
+static VALUE
+s_LAMatrix_ColumnSize(VALUE self)
+{
+ LAMatrix *mp;
+ Data_Get_Struct(self, LAMatrix, mp);
+ return INT2NUM(mp->column);
+}
+
+/*
+ * call-seq:
+ * row_size -> LAMatrix
+ *
+ * Returns the row size.
+ */
+static VALUE
+s_LAMatrix_RowSize(VALUE self)
+{
+ LAMatrix *mp;
+ Data_Get_Struct(self, LAMatrix, mp);
+ return INT2NUM(mp->row);
+}
+
+/*
+ * call-seq:
* eigenvalues -> [eigenvalues, eigenvectors]
*
* Calculate the eigenvalues and eigenvectors. The matrix must be symmetric.
rb_define_method(rb_cLAMatrix, "submatrix", s_LAMatrix_Submatrix, 4);
rb_define_method(rb_cLAMatrix, "column", s_LAMatrix_Column, 1);
rb_define_method(rb_cLAMatrix, "row", s_LAMatrix_Row, 1);
+ rb_define_method(rb_cLAMatrix, "column_size", s_LAMatrix_ColumnSize, 0);
+ rb_define_method(rb_cLAMatrix, "row_size", s_LAMatrix_RowSize, 0);
rb_define_method(rb_cLAMatrix, "eigenvalues", s_LAMatrix_Eigenvalues, 0);
rb_define_method(rb_cLAMatrix, "to_a", s_LAMatrix_ToArray, 0);
rb_define_method(rb_cLAMatrix, "inspect", s_LAMatrix_Inspect, 0);