Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-05-22 07:22:56 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-05-22 07:22:56 +0400
commite191618cb5906ad50c7b6a75f52ad54cc6a812f7 (patch)
tree88bb7ea40791392b1b6d65a5b65cd6e8cd35eafa
parent7f5acd68755cb36aa7f679ffbd41cc3c6d9cbf58 (diff)
- Deprecated Mathutils.CrossVecs(v1,v2) for v1.cross(v2), (same with .DotVecs -> v1.dot(v2), for CrossQuats and DotQuats too)
- Grouped Mathutils deprecated functions - Dont include source code in bpy epydocs
-rw-r--r--source/blender/python/api2_2x/Mathutils.h8
-rw-r--r--source/blender/python/api2_2x/doc/Mathutils.py44
-rwxr-xr-xsource/blender/python/api2_2x/doc/epy_docgen.sh2
-rw-r--r--source/blender/python/api2_2x/quat.c38
-rw-r--r--source/blender/python/api2_2x/quat.h2
-rw-r--r--source/blender/python/api2_2x/vector.c52
-rw-r--r--source/blender/python/api2_2x/vector.h4
7 files changed, 140 insertions, 10 deletions
diff --git a/source/blender/python/api2_2x/Mathutils.h b/source/blender/python/api2_2x/Mathutils.h
index b511f2046a6..789470d43c6 100644
--- a/source/blender/python/api2_2x/Mathutils.h
+++ b/source/blender/python/api2_2x/Mathutils.h
@@ -45,8 +45,6 @@ PyObject *quat_rotation(PyObject *arg1, PyObject *arg2);
PyObject *M_Mathutils_Rand(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Vector(PyObject * self, PyObject * args);
-PyObject *M_Mathutils_CrossVecs(PyObject * self, PyObject * args);
-PyObject *M_Mathutils_DotVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_AngleBetweenVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_MidpointVecs(PyObject * self, PyObject * args);
PyObject *M_Mathutils_ProjectVecs(PyObject * self, PyObject * args);
@@ -57,8 +55,6 @@ PyObject *M_Mathutils_ScaleMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_OrthoProjectionMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_ShearMatrix(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Quaternion(PyObject * self, PyObject * args);
-PyObject *M_Mathutils_CrossQuats(PyObject * self, PyObject * args);
-PyObject *M_Mathutils_DotQuats(PyObject * self, PyObject * args);
PyObject *M_Mathutils_DifferenceQuats(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Slerp(PyObject * self, PyObject * args);
PyObject *M_Mathutils_Euler(PyObject * self, PyObject * args);
@@ -75,6 +71,10 @@ PyObject *M_Mathutils_CopyEuler(PyObject * self, PyObject * args);
PyObject *M_Mathutils_RotateEuler(PyObject * self, PyObject * args);
PyObject *M_Mathutils_MatMultVec(PyObject * self, PyObject * args);
PyObject *M_Mathutils_VecMultMat(PyObject * self, PyObject * args);
+PyObject *M_Mathutils_CrossVecs(PyObject * self, PyObject * args);
+PyObject *M_Mathutils_DotVecs(PyObject * self, PyObject * args);
+PyObject *M_Mathutils_CrossQuats(PyObject * self, PyObject * args);
+PyObject *M_Mathutils_DotQuats(PyObject * self, PyObject * args);
int EXPP_FloatsAreEqual(float A, float B, int floatSteps);
int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps);
diff --git a/source/blender/python/api2_2x/doc/Mathutils.py b/source/blender/python/api2_2x/doc/Mathutils.py
index 52cd5fbcc7f..73a2ce46c4f 100644
--- a/source/blender/python/api2_2x/doc/Mathutils.py
+++ b/source/blender/python/api2_2x/doc/Mathutils.py
@@ -26,6 +26,8 @@ Example::
angle = DifferenceQuats(quat1, quat2)
print angle
+
+@group Deprecated: CopyMat, CopyVec, CopyQuat, CopyEuler, RotateEuler, MatMultVec, VecMultMat, CrossVecs, DotVecs, CrossQuats, DotQuats
"""
def Rand (low=0.0, high = 1.0):
@@ -129,6 +131,7 @@ def CopyVec(vector):
def CrossVecs(vec1, vec2):
"""
Return the cross product of two vectors.
+ @attention: B{DEPRECATED} use vector.cross(other) instead.
@type vec1: Vector object.
@param vec1: A 3d vector.
@type vec2: Vector object.
@@ -141,6 +144,7 @@ def CrossVecs(vec1, vec2):
def DotVecs(vec1, vec2):
"""
Return the dot product of two vectors.
+ @attention: B{DEPRECATED} use vector.dot(other) instead.
@type vec1: Vector object.
@param vec1: A 2d,3d or 4d vector.
@type vec2: Vector object.
@@ -323,6 +327,7 @@ def CopyQuat(quaternion):
def CrossQuats(quat1, quat2):
"""
Return the cross product of two quaternions.
+ @attention: B{DEPRECATED} use quat.cross(other) instead.
@type quat1: Quaternion object.
@param quat1: Quaternion.
@type quat2: Quaternion object.
@@ -335,6 +340,7 @@ def CrossQuats(quat1, quat2):
def DotQuats(quat1, quat2):
"""
Return the dot product of two quaternions.
+ @attention: B{DEPRECATED} use quat.dot(other) instead.
@type quat1: Quaternion object.
@param quat1: Quaternion.
@type quat2: Quaternion object.
@@ -541,6 +547,26 @@ class Vector:
@return: The reflected vector.
"""
+ def cross(other):
+ """
+ Return the cross product of this vector and another.
+ @note: both vectors must be 3D.
+ @type other: Vector object
+ @param other: The other vector to perform the cross product with.
+ @rtype: Vector
+ @return: The cross product.
+ """
+
+ def dot(other):
+ """
+ Return the dot product of this vector and another.
+ @note: both vectors must be the same size.
+ @type other: Vector object
+ @param other: The other vector to perform the dot product with.
+ @rtype: float
+ @return: The dot product.
+ """
+
class Euler:
"""
The Euler object
@@ -740,6 +766,24 @@ class Quaternion:
@return: A 3x3 rotation matrix representation of the quaternion.
"""
+ def cross(other):
+ """
+ Return the cross product of this quaternion and another.
+ @type other: Quaterion object
+ @param other: The other quaternion to perform the cross product with.
+ @rtype: Vector
+ @return: The cross product.
+ """
+
+ def dot(other):
+ """
+ Return the dot product of this quaternion and another.
+ @type other: Quaterion object
+ @param other: The other quaternion to perform the dot product with.
+ @rtype: float
+ @return: The dot product.
+ """
+
class Matrix:
"""
The Matrix Object
diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh
index 0e5350e41ae..3c903e849af 100755
--- a/source/blender/python/api2_2x/doc/epy_docgen.sh
+++ b/source/blender/python/api2_2x/doc/epy_docgen.sh
@@ -8,4 +8,4 @@
LC_ALL=POSIX
epydoc --debug -v -o BPY_API --url "http://www.blender.org" --top API_intro \
- --name "Blender" --no-private --no-frames [A-Z]*.py
+ --name "Blender" --no-private --no-sourcecode [A-Z]*.py
diff --git a/source/blender/python/api2_2x/quat.c b/source/blender/python/api2_2x/quat.c
index 14fd5f9ba4c..585b76a34dc 100644
--- a/source/blender/python/api2_2x/quat.c
+++ b/source/blender/python/api2_2x/quat.c
@@ -41,6 +41,8 @@ char Quaternion_Inverse_doc[] = "() - set the quaternion to it's inverse";
char Quaternion_Normalize_doc[] = "() - normalize the vector portion of the quaternion";
char Quaternion_ToEuler_doc[] = "(eul_compat) - return a euler rotation representing the quaternion, optional euler argument that the new euler will be made compatible with.";
char Quaternion_ToMatrix_doc[] = "() - return a rotation matrix representing the quaternion";
+char Quaternion_Cross_doc[] = "(other) - return the cross product between this quaternion and another";
+char Quaternion_Dot_doc[] = "(other) - return the dot product between this quaternion and another";
char Quaternion_copy_doc[] = "() - return a copy of the quat";
//-----------------------METHOD DEFINITIONS ----------------------
struct PyMethodDef Quaternion_methods[] = {
@@ -51,6 +53,8 @@ struct PyMethodDef Quaternion_methods[] = {
{"normalize", (PyCFunction) Quaternion_Normalize, METH_NOARGS, Quaternion_Normalize_doc},
{"toEuler", (PyCFunction) Quaternion_ToEuler, METH_VARARGS, Quaternion_ToEuler_doc},
{"toMatrix", (PyCFunction) Quaternion_ToMatrix, METH_NOARGS, Quaternion_ToMatrix_doc},
+ {"cross", (PyCFunction) Quaternion_Cross, METH_O, Quaternion_Cross_doc},
+ {"dot", (PyCFunction) Quaternion_Dot, METH_O, Quaternion_Dot_doc},
{"__copy__", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
{"copy", (PyCFunction) Quaternion_copy, METH_NOARGS, Quaternion_copy_doc},
{NULL, NULL, 0, NULL}
@@ -96,6 +100,40 @@ PyObject *Quaternion_ToMatrix(QuaternionObject * self)
return newMatrixObject(mat, 3, 3, Py_NEW);
}
+
+//----------------------------Quaternion.cross(other)------------------
+//return the cross quat
+PyObject *Quaternion_Cross(QuaternionObject * self, QuaternionObject * value)
+{
+ float quat[4];
+
+ if (!QuaternionObject_Check(value)) {
+ PyErr_SetString( PyExc_TypeError, "quat.cross(value): expected a quaternion argument" );
+ return NULL;
+ }
+
+ QuatMul(quat, self->quat, value->quat);
+ return newQuaternionObject(quat, Py_NEW);
+}
+
+//----------------------------Quaternion.dot(other)------------------
+//return the dot quat
+PyObject *Quaternion_Dot(QuaternionObject * self, QuaternionObject * value)
+{
+ int x;
+ double dot = 0.0;
+
+ if (!QuaternionObject_Check(value)) {
+ PyErr_SetString( PyExc_TypeError, "quat.dot(value): expected a quaternion argument" );
+ return NULL;
+ }
+
+ for(x = 0; x < 4; x++) {
+ dot += self->quat[x] * value->quat[x];
+ }
+ return PyFloat_FromDouble(dot);
+}
+
//----------------------------Quaternion.normalize()----------------
//normalize the axis of rotation of [theta,vector]
PyObject *Quaternion_Normalize(QuaternionObject * self)
diff --git a/source/blender/python/api2_2x/quat.h b/source/blender/python/api2_2x/quat.h
index 9f3a919bce0..84a013d9788 100644
--- a/source/blender/python/api2_2x/quat.h
+++ b/source/blender/python/api2_2x/quat.h
@@ -64,6 +64,8 @@ PyObject *Quaternion_Inverse( QuaternionObject * self );
PyObject *Quaternion_Normalize( QuaternionObject * self );
PyObject *Quaternion_ToEuler( QuaternionObject * self, PyObject *args );
PyObject *Quaternion_ToMatrix( QuaternionObject * self );
+PyObject *Quaternion_Cross( QuaternionObject * self, QuaternionObject * value );
+PyObject *Quaternion_Dot( QuaternionObject * self, QuaternionObject * value );
PyObject *Quaternion_copy( QuaternionObject * self );
PyObject *newQuaternionObject( float *quat, int type );
diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c
index f4504a13f72..cb206363dbf 100644
--- a/source/blender/python/api2_2x/vector.c
+++ b/source/blender/python/api2_2x/vector.c
@@ -47,7 +47,9 @@ char Vector_Resize2D_doc[] = "() - resize a vector to [x,y]";
char Vector_Resize3D_doc[] = "() - resize a vector to [x,y,z]";
char Vector_Resize4D_doc[] = "() - resize a vector to [x,y,z,w]";
char Vector_ToTrackQuat_doc[] = "(track, up) - extract a quaternion from the vector and the track and up axis";
-char Vector_reflect_doc[] = "(mirror) - return a vector reflected on the mirror normal";
+char Vector_Reflect_doc[] = "(mirror) - return a vector reflected on the mirror normal";
+char Vector_Cross_doc[] = "(other) - return the cross product between this vector and another";
+char Vector_Dot_doc[] = "(other) - return the dot product between this vector and another";
char Vector_copy_doc[] = "() - return a copy of the vector";
char Vector_swizzle_doc[] = "Swizzle: Get or set axes in specified order";
/*-----------------------METHOD DEFINITIONS ----------------------*/
@@ -59,7 +61,9 @@ struct PyMethodDef Vector_methods[] = {
{"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize2D_doc},
{"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize2D_doc},
{"toTrackQuat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, Vector_ToTrackQuat_doc},
- {"reflect", ( PyCFunction ) Vector_reflect, METH_O, Vector_reflect_doc},
+ {"reflect", ( PyCFunction ) Vector_Reflect, METH_O, Vector_Reflect_doc},
+ {"cross", ( PyCFunction ) Vector_Cross, METH_O, Vector_Dot_doc},
+ {"dot", ( PyCFunction ) Vector_Dot, METH_O, Vector_Cross_doc},
{"copy", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
{"__copy__", (PyCFunction) Vector_copy, METH_NOARGS, Vector_copy_doc},
{NULL, NULL, 0, NULL}
@@ -275,7 +279,7 @@ PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args )
return a reflected vector on the mirror normal
((2 * DotVecs(vec, mirror)) * mirror) - vec
using arithb.c would be nice here */
-PyObject *Vector_reflect( VectorObject * self, PyObject * value )
+PyObject *Vector_Reflect( VectorObject * self, PyObject * value )
{
VectorObject *mirrvec;
float mirror[3];
@@ -288,7 +292,7 @@ PyObject *Vector_reflect( VectorObject * self, PyObject * value )
float norm = 0.0f;
if (!VectorObject_Check(value)) {
- PyErr_SetString( PyExc_TypeError, "expected a vector argument" );
+ PyErr_SetString( PyExc_TypeError, "vec.reflect(value): expected a vector argument" );
return NULL;
}
mirrvec = (VectorObject *)value;
@@ -322,6 +326,46 @@ PyObject *Vector_reflect( VectorObject * self, PyObject * value )
return newVectorObject(reflect, self->size, Py_NEW);
}
+PyObject *Vector_Cross( VectorObject * self, VectorObject * value )
+{
+ VectorObject *vecCross = NULL;
+
+ if (!VectorObject_Check(value)) {
+ PyErr_SetString( PyExc_TypeError, "vec.cross(value): expected a vector argument" );
+ return NULL;
+ }
+
+ if(self->size != 3 || value->size != 3) {
+ PyErr_SetString(PyExc_AttributeError, "vec.cross(value): expects both vectors to be 3D\n");
+ return NULL;
+ }
+
+ vecCross = (VectorObject *)newVectorObject(NULL, 3, Py_NEW);
+ Crossf(vecCross->vec, self->vec, value->vec);
+ return (PyObject *)vecCross;
+}
+
+PyObject *Vector_Dot( VectorObject * self, VectorObject * value )
+{
+ double dot = 0.0;
+ int x;
+
+ if (!VectorObject_Check(value)) {
+ PyErr_SetString( PyExc_TypeError, "vec.cross(value): expected a vector argument" );
+ return NULL;
+ }
+
+ if(self->size != value->size) {
+ PyErr_SetString(PyExc_AttributeError, "vec.dot(value): expects both vectors to have the same size\n");
+ return NULL;
+ }
+
+ for(x = 0; x < self->size; x++) {
+ dot += self->vec[x] * value->vec[x];
+ }
+ return PyFloat_FromDouble(dot);
+}
+
/*----------------------------Vector.copy() --------------------------------------
return a copy of the vector */
PyObject *Vector_copy(VectorObject * self)
diff --git a/source/blender/python/api2_2x/vector.h b/source/blender/python/api2_2x/vector.h
index 9ec2eff8047..94827935ebb 100644
--- a/source/blender/python/api2_2x/vector.h
+++ b/source/blender/python/api2_2x/vector.h
@@ -51,7 +51,9 @@ PyObject *Vector_Resize2D( VectorObject * self );
PyObject *Vector_Resize3D( VectorObject * self );
PyObject *Vector_Resize4D( VectorObject * self );
PyObject *Vector_ToTrackQuat( VectorObject * self, PyObject * args );
-PyObject *Vector_reflect( VectorObject * self, PyObject * value );
+PyObject *Vector_Reflect( VectorObject * self, PyObject * value );
+PyObject *Vector_Cross( VectorObject * self, VectorObject * value );
+PyObject *Vector_Dot( VectorObject * self, VectorObject * value );
PyObject *Vector_copy( VectorObject * self );
PyObject *newVectorObject(float *vec, int size, int type);