Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update quaternion.py #27399

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions sympy/algebras/quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,32 @@ def index_vector(self):
"""

return self.norm() * self.axis()
def curl(self, x, y, z):
"""
Computes the curl of the vector field represented by the quaternion.
The quaternion is assumed to represent a 3D vector field, i.e.,
q = xi + yj + zk (where a = 0).

Parameters
----------
x, y, z : symbols
The coordinates of the vector field.

Returns
-------
Quaternion
The quaternion representing the curl of the vector field.
"""
# Extract the components of the quaternion (assuming it's a vector field)
xi, yi, zi = self.b, self.c, self.d # components of i, j, k

# Compute partial derivatives of the components
curl_x = diff(zi, y) - diff(yi, z)
curl_y = diff(xi, z) - diff(zi, x)
curl_z = diff(yi, x) - diff(xi, y)

# Return a quaternion representing the curl (using i, j, k)
return Quaternion(0, curl_x, curl_y, curl_z)

def mensor(self):
"""
Expand Down
Loading