Represents a coordinate system in 3-D space.
The orientation/location parameters are necessary if this system is being defined at a certain orientation or location wrt another.
Parameters : | name : str
location : Vector
rotation_matrix : SymPy ImmutableMatrix
parent : CoordSysCartesian
vector_names, variable_names : iterable(optional)
|
---|
Returns a CoordSysCartesian with its origin located at the given position wrt this coordinate system’s origin.
Parameters : | name : str
position : Vector
vector_names, variable_names : iterable(optional)
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> A = CoordSysCartesian('A')
>>> B = A.locate_new('B', 10 * A.i)
>>> B.origin.position_wrt(A.origin)
10*A.i
Creates a new CoordSysCartesian oriented in the user-specified way with respect to this system.
Please refer to the documentation of the orienter classes for more information about the orientation procedure.
Parameters : | name : str
orienters : iterable/Orienter
location : Vector(optional)
vector_names, variable_names : iterable(optional)
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import symbols
>>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3')
>>> N = CoordSysCartesian('N')
Using an AxisOrienter
>>> from sympy.vector import AxisOrienter
>>> axis_orienter = AxisOrienter(q1, N.i + 2 * N.j)
>>> A = N.orient_new('A', (axis_orienter, ))
Using a BodyOrienter
>>> from sympy.vector import BodyOrienter
>>> body_orienter = BodyOrienter(q1, q2, q3, '123')
>>> B = N.orient_new('B', (body_orienter, ))
Using a SpaceOrienter
>>> from sympy.vector import SpaceOrienter
>>> space_orienter = SpaceOrienter(q1, q2, q3, '312')
>>> C = N.orient_new('C', (space_orienter, ))
Using a QuaternionOrienter
>>> from sympy.vector import QuaternionOrienter
>>> q_orienter = QuaternionOrienter(q0, q1, q2, q3)
>>> D = N.orient_new('D', (q_orienter, ))
Axis rotation is a rotation about an arbitrary axis by some angle. The angle is supplied as a SymPy expr scalar, and the axis is supplied as a Vector.
Parameters : | name : string
angle : Expr
axis : Vector
location : Vector(optional)
vector_names, variable_names : iterable(optional)
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = CoordSysCartesian('N')
>>> B = N.orient_new_axis('B', q1, N.i + 2 * N.j)
Body orientation takes this coordinate system through three successive simple rotations.
Body fixed rotations include both Euler Angles and Tait-Bryan Angles, see http://en.wikipedia.org/wiki/Euler_angles.
Parameters : | name : string
angle1, angle2, angle3 : Expr
rotation_order : string
location : Vector(optional)
vector_names, variable_names : iterable(optional)
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import symbols
>>> q1, q2, q3 = symbols('q1 q2 q3')
>>> N = CoordSysCartesian('N')
A ‘Body’ fixed rotation is described by three angles and three body-fixed rotation axes. To orient a coordinate system D with respect to N, each sequential rotation is always about the orthogonal unit vectors fixed to D. For example, a ‘123’ rotation will specify rotations about N.i, then D.j, then D.k. (Initially, D.i is same as N.i) Therefore,
>>> D = N.orient_new_body('D', q1, q2, q3, '123')
is same as
>>> D = N.orient_new_axis('D', q1, N.i)
>>> D = D.orient_new_axis('D', q2, D.j)
>>> D = D.orient_new_axis('D', q3, D.k)
Acceptable rotation orders are of length 3, expressed in XYZ or 123, and cannot have a rotation about about an axis twice in a row.
>>> B = N.orient_new_body('B', q1, q2, q3, '123')
>>> B = N.orient_new_body('B', q1, q2, 0, 'ZXZ')
>>> B = N.orient_new_body('B', 0, 0, 0, 'XYX')
Quaternion orientation orients the new CoordSysCartesian with Quaternions, defined as a finite rotation about lambda, a unit vector, by some amount theta.
This orientation is described by four parameters:
q0 = cos(theta/2)
q1 = lambda_x sin(theta/2)
q2 = lambda_y sin(theta/2)
q3 = lambda_z sin(theta/2)
Quaternion does not take in a rotation order.
Parameters : | name : string
q0, q1, q2, q3 : Expr
location : Vector(optional)
vector_names, variable_names : iterable(optional)
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import symbols
>>> q0, q1, q2, q3 = symbols('q0 q1 q2 q3')
>>> N = CoordSysCartesian('N')
>>> B = N.orient_new_quaternion('B', q0, q1, q2, q3)
Space rotation is similar to Body rotation, but the rotations are applied in the opposite order.
Parameters : | name : string
angle1, angle2, angle3 : Expr
rotation_order : string
location : Vector(optional)
vector_names, variable_names : iterable(optional)
|
---|
See also
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import symbols
>>> q1, q2, q3 = symbols('q1 q2 q3')
>>> N = CoordSysCartesian('N')
To orient a coordinate system D with respect to N, each sequential rotation is always about N’s orthogonal unit vectors. For example, a ‘123’ rotation will specify rotations about N.i, then N.j, then N.k. Therefore,
>>> D = N.orient_new_space('D', q1, q2, q3, '312')
is same as
>>> B = N.orient_new_axis('B', q1, N.i)
>>> C = B.orient_new_axis('C', q2, N.j)
>>> D = C.orient_new_axis('D', q3, N.k)
Returns the position vector of the origin of this coordinate system with respect to another Point/CoordSysCartesian.
Parameters : | other : Point/CoordSysCartesian
|
---|
Examples
>>> from sympy.vector import Point, CoordSysCartesian
>>> N = CoordSysCartesian('N')
>>> N1 = N.locate_new('N1', 10 * N.i)
>>> N.position_wrt(N1)
(-10)*N.i
Returns the direction cosine matrix(DCM), also known as the ‘rotation matrix’ of this coordinate system with respect to another system.
If v_a is a vector defined in system ‘A’ (in matrix format) and v_b is the same vector defined in system ‘B’, then v_a = A.rotation_matrix(B) * v_b.
A SymPy Matrix is returned.
Parameters : | other : CoordSysCartesian
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import symbols
>>> q1 = symbols('q1')
>>> N = CoordSysCartesian('N')
>>> A = N.orient_new_axis('A', q1, N.i)
>>> N.rotation_matrix(A)
Matrix([
[1, 0, 0],
[0, cos(q1), -sin(q1)],
[0, sin(q1), cos(q1)]])
Returns a dictionary which expresses the coordinate variables (base scalars) of this frame in terms of the variables of otherframe.
Parameters : | otherframe : CoordSysCartesian
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> from sympy import Symbol
>>> A = CoordSysCartesian('A')
>>> q = Symbol('q')
>>> B = A.orient_new_axis('B', q, A.k)
>>> A.scalar_map(B)
{A.x: -sin(q)*B.y + cos(q)*B.x, A.y: sin(q)*B.x + cos(q)*B.y, A.z: B.z}
Super class for all Vector classes. Ideally, neither this class nor any of its subclasses should be instantiated by the user.
Returns the components of this vector in the form of a Python dictionary mapping BaseVector instances to the corresponding measure numbers.
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> v = 3*C.i + 4*C.j + 5*C.k
>>> v.components
{C.i: 3, C.j: 4, C.k: 5}
Returns the cross product of this Vector with another Vector or Dyadic instance. The cross product is a Vector, if ‘other’ is a Vector. If ‘other’ is a Dyadic, this returns a Dyadic instance.
Parameters : | other: Vector/Dyadic
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> C.i.cross(C.j)
C.k
>>> C.i ^ C.i
0
>>> v = 3*C.i + 4*C.j + 5*C.k
>>> v ^ C.i
5*C.j + (-4)*C.k
>>> d = C.i.outer(C.i)
>>> C.j.cross(d)
(-1)*(C.k|C.i)
Returns the dot product of this Vector, either with another Vector, or a Dyadic, or a Del operator. If ‘other’ is a Vector, returns the dot product scalar (Sympy expression). If ‘other’ is a Dyadic, the dot product is returned as a Vector. If ‘other’ is an instance of Del, returns the directional derivate operator as a Python function. If this function is applied to a scalar expression, it returns the directional derivative of the scalar field wrt this Vector.
Parameters : | other: Vector/Dyadic/Del
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> C.i.dot(C.j)
0
>>> C.i & C.i
1
>>> v = 3*C.i + 4*C.j + 5*C.k
>>> v.dot(C.k)
5
>>> (C.i & C.delop)(C.x*C.y*C.z)
C.y*C.z
>>> d = C.i.outer(C.i)
>>> C.i.dot(d)
C.i
Returns the outer product of this vector with another, in the form of a Dyadic instance.
Parameters : | other : Vector
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> N = CoordSysCartesian('N')
>>> N.i.outer(N.j)
(N.i|N.j)
Returns the vector or scalar projection of the ‘other’ on ‘self’.
Examples
>>> from sympy.vector.coordsysrect import CoordSysCartesian
>>> from sympy.vector.vector import Vector, BaseVector
>>> C = CoordSysCartesian('C')
>>> i, j, k = C.base_vectors()
>>> v1 = i + j + k
>>> v2 = 3*i + 4*j
>>> v1.projection(v2)
7/3*C.i + 7/3*C.j + 7/3*C.k
>>> v1.projection(v2, scalar=True)
7/3
The constituents of this vector in different coordinate systems, as per its definition.
Returns a dict mapping each CoordSysCartesian to the corresponding constituent Vector.
Examples
>>> from sympy.vector import CoordSysCartesian
>>> R1 = CoordSysCartesian('R1')
>>> R2 = CoordSysCartesian('R2')
>>> v = R1.i + R2.i
>>> v.separate() == {R1: R1.i, R2: R2.i}
True
Returns the matrix form of this vector with respect to the specified coordinate system.
Parameters : | system : CoordSysCartesian
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> from sympy.abc import a, b, c
>>> v = a*C.i + b*C.j + c*C.k
>>> v.to_matrix(C)
Matrix([
[a],
[b],
[c]])
Super class for all Dyadic-classes.
References
[R532] | http://en.wikipedia.org/wiki/Dyadic_tensor |
[R533] | Kane, T., Levinson, D. Dynamics Theory and Applications. 1985 McGraw-Hill |
Returns the components of this dyadic in the form of a Python dictionary mapping BaseDyadic instances to the corresponding measure numbers.
Returns the cross product between this Dyadic, and a Vector, as a Vector instance.
Parameters : | other : Vector
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> N = CoordSysCartesian('N')
>>> d = N.i.outer(N.i)
>>> d.cross(N.j)
(N.i|N.k)
Returns the dot product(also called inner product) of this Dyadic, with another Dyadic or Vector. If ‘other’ is a Dyadic, this returns a Dyadic. Else, it returns a Vector (unless an error is encountered).
Parameters : | other : Dyadic/Vector
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> N = CoordSysCartesian('N')
>>> D1 = N.i.outer(N.j)
>>> D2 = N.j.outer(N.j)
>>> D1.dot(D2)
(N.i|N.j)
>>> D1.dot(N.j)
N.i
Returns the matrix form of the dyadic with respect to one or two coordinate systems.
Parameters : | system : CoordSysCartesian
second_system : CoordSysCartesian, optional, default=None
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> N = CoordSysCartesian('N')
>>> v = N.i + 2*N.j
>>> d = v.outer(N.i)
>>> d.to_matrix(N)
Matrix([
[1, 0, 0],
[2, 0, 0],
[0, 0, 0]])
>>> from sympy import Symbol
>>> q = Symbol('q')
>>> P = N.orient_new_axis('P', q, N.k)
>>> d.to_matrix(N, P)
Matrix([
[ cos(q), -sin(q), 0],
[2*cos(q), -2*sin(q), 0],
[ 0, 0, 0]])
Represents the vector differential operator, usually represented in mathematical expressions as the ‘nabla’ symbol.
Represents the cross product between this operator and a given vector - equal to the curl of the vector field.
Parameters : | vect : Vector
doit : bool
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> v = C.x*C.y*C.z * (C.i + C.j + C.k)
>>> C.delop.cross(v, doit = True)
(-C.x*C.y + C.x*C.z)*C.i + (C.x*C.y - C.y*C.z)*C.j + (-C.x*C.z + C.y*C.z)*C.k
>>> (C.delop ^ C.i).doit()
0
Represents the dot product between this operator and a given vector - equal to the divergence of the vector field.
Parameters : | vect : Vector
doit : bool
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> C.delop.dot(C.x*C.i)
Derivative(C.x, C.x)
>>> v = C.x*C.y*C.z * (C.i + C.j + C.k)
>>> (C.delop & v).doit()
C.x*C.y + C.x*C.z + C.y*C.z
Returns the gradient of the given scalar field, as a Vector instance.
Parameters : | scalar_field : SymPy expression
doit : bool
|
---|
Examples
>>> from sympy.vector import CoordSysCartesian
>>> C = CoordSysCartesian('C')
>>> C.delop.gradient(9)
(Derivative(9, C.x))*C.i + (Derivative(9, C.y))*C.j + (Derivative(9, C.z))*C.k
>>> C.delop(C.x*C.y*C.z).doit()
C.y*C.z*C.i + C.x*C.z*C.j + C.x*C.y*C.k