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

[WIP] Reconstruction constructor in CoordSys3D #13056

Merged
merged 29 commits into from Aug 12, 2017
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1cf0d8e
Add structure for transformation equations in constructor.
szymag Jul 27, 2017
bc16490
Merge branch 'master' into reconstruction_constructor
szymag Jul 27, 2017
6cb3a2e
Add transformation equations.
szymag Jul 27, 2017
bc6d63d
Update coordsysrect.py
Upabjojr Jul 27, 2017
b227693
Update _rotation_trans_equations, _translation_trans_equations.
szymag Jul 29, 2017
165b98c
Update constructor.
szymag Jul 29, 2017
d08dc10
Check orthogonality in constructor.
szymag Jul 29, 2017
6925316
Update code appling Upabjojr suggestion.
szymag Jul 31, 2017
181c2a5
Adapt methods for transformation.
szymag Aug 1, 2017
705fd5c
Update coordsysrect.py
Upabjojr Aug 2, 2017
e4a29c7
Update coordsysrect.py
Upabjojr Aug 2, 2017
a1628b8
Update CoordSys3D.
szymag Aug 2, 2017
74a491c
Apply comments.
szymag Aug 3, 2017
ad3b703
Pass tests from test_coordsysret.py.
szymag Aug 4, 2017
00942fb
Reduce overhead comming from creating transfotmation.
szymag Aug 5, 2017
2fe8fc7
Huge refactory to CoordSys3D constructor
Upabjojr Aug 7, 2017
30fdac9
Support for custom transformation equations.
szymag Aug 9, 2017
198501b
Fix base vectors, base scalars name printing.
szymag Aug 9, 2017
ef8537b
Fixes to gradient/divergence/curl
Upabjojr Aug 9, 2017
42783d4
inverse transformation for rotation/translation
Upabjojr Aug 9, 2017
8a517c3
Revert unwanted changes
szymag Aug 9, 2017
0219eab
Revert unwanted changes
szymag Aug 9, 2017
ee3226e
Merge branch 'reconstruction_constructor' of https://github.com/szyma…
szymag Aug 10, 2017
8aef7e4
Merge branch 'master' into reconstruction_constructor
szymag Aug 10, 2017
78e9bd4
Merge branch 'master' into reconstruction_constructor
szymag Aug 10, 2017
bebff57
Merge branch 'reconstruction_constructor' of https://github.com/szyma…
szymag Aug 10, 2017
a6fc5bd
Revert order in transformation.
szymag Aug 10, 2017
c242261
fixes to directional_derivative, tests restored
Upabjojr Aug 10, 2017
063ab1b
Fix printing error.
szymag Aug 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions sympy/core/tests/test_args.py
Expand Up @@ -3870,7 +3870,7 @@ def test_sympy__vector__vector__BaseVector():
from sympy.vector.vector import BaseVector
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(BaseVector('Ci', 0, C, ' ', ' '))
assert _test_args(BaseVector(0, C, ' ', ' '))


def test_sympy__vector__vector__VectorAdd():
Expand Down Expand Up @@ -4013,7 +4013,7 @@ def test_sympy__vector__scalar__BaseScalar():
from sympy.vector.scalar import BaseScalar
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(BaseScalar('Cx', 0, C, ' ', ' '))
assert _test_args(BaseScalar(0, C, ' ', ' '))


def test_sympy__physics__wigner__Wigner3j():
Expand Down
502 changes: 244 additions & 258 deletions sympy/vector/coordsysrect.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions sympy/vector/functions.py
Expand Up @@ -48,7 +48,7 @@ def express(expr, system, system2=None, variables=False):
>>> express(B.i, N)
(cos(q))*N.i + (sin(q))*N.j
>>> express(N.x, B, variables=True)
-sin(q)*B.y + cos(q)*B.x
B.x*cos(q) - B.y*sin(q)
>>> d = N.i.outer(N.i)
>>> express(d, B, N) == (cos(q))*(B.i|N.i) + (-sin(q))*(B.j|N.i)
True
Expand Down Expand Up @@ -157,9 +157,9 @@ def directional_derivative(field, direction_vector):
coord_sys = _get_coord_sys_from_expr(field)
if coord_sys is not None:
field = express(field, coord_sys, variables=True)
out = Vector.dot(direction_vector, coord_sys._i) * diff(field, coord_sys._x)
out += Vector.dot(direction_vector, coord_sys._j) * diff(field, coord_sys._y)
out += Vector.dot(direction_vector, coord_sys._k) * diff(field, coord_sys._z)
out = Vector.dot(direction_vector, coord_sys.i) * diff(field, coord_sys.x)
out += Vector.dot(direction_vector, coord_sys.j) * diff(field, coord_sys.y)
out += Vector.dot(direction_vector, coord_sys.k) * diff(field, coord_sys.z)
if out == 0 and isinstance(field, Vector):
out = Vector.zero
return out
Expand Down
55 changes: 32 additions & 23 deletions sympy/vector/operators.py
Expand Up @@ -140,20 +140,24 @@ def curl(vect, coord_sys=None, doit=True):
"""

coord_sys = _get_coord_sys_from_expr(vect, coord_sys)

if coord_sys is None:
return Vector.zero
else:
i, j, k = coord_sys.base_vectors()
x, y, z = coord_sys.base_scalars()
h1, h2, h3 = coord_sys.lame_coefficients()
from sympy.vector.functions import express
vectx = express(vect.dot(coord_sys._i), coord_sys, variables=True)
vecty = express(vect.dot(coord_sys._j), coord_sys, variables=True)
vectz = express(vect.dot(coord_sys._k), coord_sys, variables=True)
vectx = express(vect.dot(i), coord_sys, variables=True)
vecty = express(vect.dot(j), coord_sys, variables=True)
vectz = express(vect.dot(k), coord_sys, variables=True)
outvec = Vector.zero
outvec += (Derivative(vectz * coord_sys._h3, coord_sys._y) -
Derivative(vecty * coord_sys._h2, coord_sys._z)) * coord_sys._i / (coord_sys._h2 * coord_sys._h3)
outvec += (Derivative(vectx * coord_sys._h1, coord_sys._z) -
Derivative(vectz * coord_sys._h3, coord_sys._x)) * coord_sys._j / (coord_sys._h1 * coord_sys._h3)
outvec += (Derivative(vecty * coord_sys._h2, coord_sys._x) -
Derivative(vectx * coord_sys._h1, coord_sys._y)) * coord_sys._k / (coord_sys._h2 * coord_sys._h1)
outvec += (Derivative(vectz * h3, y) -
Derivative(vecty * h2, z)) * i / (h2 * h3)
outvec += (Derivative(vectx * h1, z) -
Derivative(vectz * h3, x)) * j / (h1 * h3)
outvec += (Derivative(vecty * h2, x) -
Derivative(vectx * h1, y)) * k / (h2 * h1)

if doit:
return outvec.doit()
Expand Down Expand Up @@ -194,17 +198,20 @@ def divergence(vect, coord_sys=None, doit=True):
2*R.z

"""

coord_sys = _get_coord_sys_from_expr(vect, coord_sys)

if coord_sys is None:
return S.Zero
else:
vx = _diff_conditional(vect.dot(coord_sys._i), coord_sys._x, coord_sys._h2, coord_sys._h3) \
/ (coord_sys._h1 * coord_sys._h2 * coord_sys._h3)
vy = _diff_conditional(vect.dot(coord_sys._j), coord_sys._y, coord_sys._h3, coord_sys._h1) \
/ (coord_sys._h1 * coord_sys._h2 * coord_sys._h3)
vz = _diff_conditional(vect.dot(coord_sys._k), coord_sys._z, coord_sys._h1, coord_sys._h2) \
/ (coord_sys._h1 * coord_sys._h2 * coord_sys._h3)
i, j, k = coord_sys.base_vectors()
x, y, z = coord_sys.base_scalars()
h1, h2, h3 = coord_sys.lame_coefficients()
vx = _diff_conditional(vect.dot(i), x, h2, h3) \
/ (h1 * h2 * h3)
vy = _diff_conditional(vect.dot(j), y, h3, h1) \
/ (h1 * h2 * h3)
vz = _diff_conditional(vect.dot(k), z, h1, h2) \
/ (h1 * h2 * h3)
if doit:
return (vx + vy + vz).doit()
return vx + vy + vz
Expand Down Expand Up @@ -249,15 +256,17 @@ def gradient(scalar_field, coord_sys=None, doit=True):
return Vector.zero
else:
from sympy.vector.functions import express
scalar_field = express(scalar_field, coord_sys,
variables=True)
vx = Derivative(scalar_field, coord_sys._x) / coord_sys._h1
vy = Derivative(scalar_field, coord_sys._y) / coord_sys._h2
vz = Derivative(scalar_field, coord_sys._z) / coord_sys._h3
h1, h2, h3 = coord_sys.lame_coefficients()
i, j, k = coord_sys.base_vectors()
x, y, z = coord_sys.base_scalars()
scalar_field = express(scalar_field, coord_sys, variables=True)
vx = Derivative(scalar_field, x) / h1
vy = Derivative(scalar_field, y) / h2
vz = Derivative(scalar_field, z) / h3

if doit:
return (vx * coord_sys._i + vy * coord_sys._j + vz * coord_sys._k).doit()
return vx * coord_sys._i + vy * coord_sys._j + vz * coord_sys._k
return (vx * i + vy * j + vz * k).doit()
return vx * i + vy * j + vz * k


def _diff_conditional(expr, base_scalar, coeff_1, coeff_2):
Expand Down
22 changes: 11 additions & 11 deletions sympy/vector/scalar.py
@@ -1,11 +1,11 @@
from sympy.core import Expr, Symbol, S
from sympy.core import AtomicExpr, Symbol, S
from sympy.core.sympify import _sympify
from sympy.core.compatibility import range
from sympy.printing.pretty.stringpict import prettyForm
from sympy.printing.precedence import PRECEDENCE


class BaseScalar(Expr):
class BaseScalar(AtomicExpr):
"""
A coordinate symbol/base scalar.

Expand All @@ -15,27 +15,27 @@ class BaseScalar(Expr):

"""

def __new__(cls, name, index, system, pretty_str, latex_str):
def __new__(cls, index, system, pretty_str=None, latex_str=None):
from sympy.vector.coordsysrect import CoordSys3D
if isinstance(name, Symbol):
name = name.name
if isinstance(pretty_str, Symbol):
if pretty_str is None:
pretty_str = "x{0}".format(index)
elif isinstance(pretty_str, Symbol):
pretty_str = pretty_str.name
if isinstance(latex_str, Symbol):
if latex_str is None:
latex_str = "x_{0}".format(index)
elif isinstance(latex_str, Symbol):
latex_str = latex_str.name

index = _sympify(index)
system = _sympify(system)
obj = super(BaseScalar, cls).__new__(cls, Symbol(name), index, system,
Symbol(pretty_str),
Symbol(latex_str))
obj = super(BaseScalar, cls).__new__(cls, index, system)
if not isinstance(system, CoordSys3D):
raise TypeError("system should be a CoordSys3D")
if index not in range(0, 3):
raise ValueError("Invalid index specified.")
# The _id is used for equating purposes, and for hashing
obj._id = (index, system)
obj._name = obj.name = name
obj._name = obj.name = system._name + '.' + system._variable_names[index]
obj._pretty_form = u'' + pretty_str
obj._latex_form = latex_str
obj._system = system
Expand Down
161 changes: 77 additions & 84 deletions sympy/vector/tests/test_coordsysrect.py
Expand Up @@ -75,10 +75,10 @@ def test_coordinate_vars():
"""
A = CoordSys3D('A')
# Note that the name given on the lhs is different from A.x._name
assert BaseScalar('A.x', 0, A, 'A_x', r'\mathbf{{x}_{A}}') == A.x
assert BaseScalar('A.y', 1, A, 'A_y', r'\mathbf{{y}_{A}}') == A.y
assert BaseScalar('A.z', 2, A, 'A_z', r'\mathbf{{z}_{A}}') == A.z
assert BaseScalar('A.x', 0, A, 'A_x', r'\mathbf{{x}_{A}}').__hash__() == A.x.__hash__()
assert BaseScalar(0, A, 'A_x', r'\mathbf{{x}_{A}}') == A.x
assert BaseScalar(1, A, 'A_y', r'\mathbf{{y}_{A}}') == A.y
assert BaseScalar(2, A, 'A_z', r'\mathbf{{z}_{A}}') == A.z
assert BaseScalar(0, A, 'A_x', r'\mathbf{{x}_{A}}').__hash__() == A.x.__hash__()
assert isinstance(A.x, BaseScalar) and \
isinstance(A.y, BaseScalar) and \
isinstance(A.z, BaseScalar)
Expand Down Expand Up @@ -299,84 +299,74 @@ def test_evalf():
assert v.evalf(subs={a:1}) == v.subs(a, 1).evalf()


def test_lame_coefficients():
a = CoordSys3D('a')
a._set_lame_coefficient_mapping('spherical')
assert a.lame_coefficients() == (1, a.x, sin(a.y)*a.x)
a = CoordSys3D('a')
assert a.lame_coefficients() == (1, 1, 1)
a = CoordSys3D('a')
a._set_lame_coefficient_mapping('cartesian')
assert a.lame_coefficients() == (1, 1, 1)
a = CoordSys3D('a')
a._set_lame_coefficient_mapping('cylindrical')
assert a.lame_coefficients() == (1, a.y, 1)


def test_transformation_equations():
from sympy import symbols

x, y, z = symbols('x y z')
a = CoordSys3D('a')
#r, theta, phi = symbols("r theta phi")
# Str
a._connect_to_standard_cartesian('spherical')
assert a._transformation_equations() == (a.x * sin(a.y) * cos(a.z),
a.x * sin(a.y) * sin(a.z),
a.x * cos(a.y))
assert a.lame_coefficients() == (1, a.x, a.x * sin(a.y))
assert a._inverse_transformation_equations() == (sqrt(a.x**2 + a.y**2 +a.z**2),
acos((a.z) / sqrt(a.x**2 + a.y**2 + a.z**2)),
atan2(a.y, a.x))
a._connect_to_standard_cartesian('cylindrical')
assert a._transformation_equations() == (a.x * cos(a.y), a.x * sin(a.y), a.z)
assert a.lame_coefficients() == (1, a.y, 1)
assert a._inverse_transformation_equations() == (sqrt(a.x**2 + a.y**2),
atan2(a.y, a.x), a.z)
a._connect_to_standard_cartesian('cartesian')
assert a._transformation_equations() == (a.x, a.y, a.z)
a = CoordSys3D('a', transformation='spherical',
variable_names=["r", "theta", "phi"])
r, theta, phi = a.base_scalars()

assert r == a.r
assert theta == a.theta
assert phi == a.phi

raises(AttributeError, lambda: a.x)
raises(AttributeError, lambda: a.y)
raises(AttributeError, lambda: a.z)

assert a.transformation_to_parent() == (
r*sin(theta)*cos(phi),
r*sin(theta)*sin(phi),
r*cos(theta)
)
assert a.lame_coefficients() == (1, r, r*sin(theta))
assert a.transformation_from_parent_function()(x, y, z) == (
sqrt(x ** 2 + y ** 2 + z ** 2),
acos((z) / sqrt(x**2 + y**2 + z**2)),
atan2(y, x)
)
a = CoordSys3D('a', transformation='cylindrical',
variable_names=["r", "theta", "z"])
r, theta, z = a.base_scalars()
assert a.transformation_to_parent() == (
r*cos(theta),
r*sin(theta),
z
)
assert a.lame_coefficients() == (1, a.theta, 1)
assert a.transformation_from_parent_function()(x, y, z) == (sqrt(x**2 + y**2),
atan2(y, x), z)
a = CoordSys3D('a', transformation='cartesian')
assert a.transformation_to_parent() == (a.x, a.y, a.z)
assert a.lame_coefficients() == (1, 1, 1)
assert a._inverse_transformation_equations() == (a.x, a.y, a.z)
assert a.transformation_from_parent_function()(x, y, z) == (x, y, z)
# Variables and expressions
a._connect_to_standard_cartesian(((x, y, z), (x, y, z)))
assert a._transformation_equations() == (a.x, a.y, a.z)
x, y, z = symbols('x y z')
a = CoordSys3D('a', transformation=((x, y, z), (x, y, z)))
a._calculate_inv_trans_equations()
assert a.transformation_to_parent() == (a.x, a.y, a.z)
assert a.lame_coefficients() == (1, 1, 1)
assert a._inverse_transformation_equations() == (a.x, a.y, a.z)
a._connect_to_standard_cartesian(((x, y, z), ((x * cos(y), x * sin(y), z))), inverse=False)
assert a._transformation_equations() == (a.x * cos(a.y), a.x * sin(a.y), a.z)
assert a.transformation_from_parent_function()(x, y, z) == (x, y, z)
a = CoordSys3D('a', transformation=(((x*cos(y), x*sin(y), z)), (x, y, z)))
assert a.transformation_to_parent() == (a.x * cos(a.y), a.x * sin(a.y), a.z)
assert simplify(a.lame_coefficients()) == (1, sqrt(a.x**2), 1)
a._connect_to_standard_cartesian(((x, y, z), (x * sin(y) * cos(z), x * sin(y) * sin(z), x * cos(y))), inverse=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the block from here on still missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not support now these type of transformation.
Here we mainly tested _connect_to_standard_cartesian which now is removed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pass a lambda to CoordSys3D constructor. You added support for this tuples.

assert a._transformation_equations() == (a.x * sin(a.y) * cos(a.z),
a.x * sin(a.y) * sin(a.z),
a.x * cos(a.y))
assert simplify(a.lame_coefficients()) == (1, sqrt(a.x**2), sqrt(sin(a.y)**2*a.x**2))
# Equations
a._connect_to_standard_cartesian((a.x*sin(a.y)*cos(a.z), a.x*sin(a.y)*sin(a.z), a.x*cos(a.y)), inverse=False)
assert a._transformation_equations() == (a.x * sin(a.y) * cos(a.z),
a.x * sin(a.y) * sin(a.z),
a.x * cos(a.y))
assert simplify(a.lame_coefficients()) == (1, sqrt(a.x**2), sqrt(sin(a.y)**2*a.x**2))
a._connect_to_standard_cartesian((a.x, a.y, a.z))
assert a._transformation_equations() == (a.x, a.y, a.z)
assert simplify(a.lame_coefficients()) == (1, 1, 1)
assert a._inverse_transformation_equations() == (a.x, a.y, a.z)
a._connect_to_standard_cartesian((a.x * cos(a.y), a.x * sin(a.y), a.z), inverse=False)
assert a._transformation_equations() == (a.x * cos(a.y), a.x * sin(a.y), a.z)
assert simplify(a.lame_coefficients()) == (1, sqrt(a.x**2), 1)

raises(ValueError, lambda: a._connect_to_standard_cartesian((x, y, z)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can test invalid parameters to the constructor



def test_check_orthogonality():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why has this test disappeared?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must did it earlier, but I shouldn't. I will do it

a = CoordSys3D('a')
a._connect_to_standard_cartesian((a.x*sin(a.y)*cos(a.z), a.x*sin(a.y)*sin(a.z), a.x*cos(a.y)), inverse=False)
assert a._check_orthogonality() is True
a._connect_to_standard_cartesian((a.x * cos(a.y), a.x * sin(a.y), a.z))
assert a._check_orthogonality() is True
a._connect_to_standard_cartesian((cosh(a.x)*cos(a.y), sinh(a.x)*sin(a.y), a.z), inverse=False)
assert a._check_orthogonality() is True
x, y, z = symbols('x y z')
u,v = symbols('u, v')
a = CoordSys3D('a', transformation=((x*sin(y)*cos(z), x*sin(y)*sin(z), x*cos(y)), (x, y, z)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the tuple (x, y, z) come before the expression?

That's why I suggest to simply use: lambda x, y, z: (x*sin(y)*cos(z), x*sin(y)*sin(z), x*cos(y))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add also support for lambda.

assert a._check_orthogonality(a._transformation) is True
a = CoordSys3D('a', transformation=((x * cos(y), x * sin(y), z), (x, y, z)))
assert a._check_orthogonality(a._transformation) is True
a = CoordSys3D('a', transformation=((cosh(u) * cos(v), sinh(u) * sin(v), z), (u, v, z)))
assert a._check_orthogonality(a._transformation) is True

raises(ValueError, lambda: a._connect_to_standard_cartesian((a.x, a.x, a.z)))
raises(ValueError, lambda: a._connect_to_standard_cartesian(
(a.x*sin(a.y / 2)*cos(a.z), a.x*sin(a.y)*sin(a.z), a.x*cos(a.y)), inverse=False))
raises(ValueError, lambda: CoordSys3D('a', transformation=((x, x, z), (x, y, z))))
raises(ValueError, lambda: CoordSys3D('a', transformation=(
(x*sin(y/2)*cos(z), x*sin(y)*sin(z), x*cos(y)), (x, y, z))))


def test_coordsys3d():
Expand All @@ -389,27 +379,30 @@ def test_rotation_trans_equations():
a = CoordSys3D('a')
from sympy import symbols
q0 = symbols('q0')
assert a._rotation_trans_equations(a._parent_rotation_matrix) == (a.x, a.y, a.z)
assert a._rotation_trans_equations(a._inverse_rotation_matrix()) == (a.x, a.y, a.z)
assert a._rotation_trans_equations(a._parent_rotation_matrix, a.base_scalars()) == (a.x, a.y, a.z)
assert a._rotation_trans_equations(a._inverse_rotation_matrix(), a.base_scalars()) == (a.x, a.y, a.z)
b = a.orient_new_axis('b', 0, -a.k)
assert b._rotation_trans_equations(b._parent_rotation_matrix) == (b.x, b.y, b.z)
assert b._rotation_trans_equations(b._inverse_rotation_matrix()) == (b.x, b.y, b.z)
assert b._rotation_trans_equations(b._parent_rotation_matrix, b.base_scalars()) == (b.x, b.y, b.z)
assert b._rotation_trans_equations(b._inverse_rotation_matrix(), b.base_scalars()) == (b.x, b.y, b.z)
c = a.orient_new_axis('c', q0, -a.k)
assert c._rotation_trans_equations(c._parent_rotation_matrix) == \
assert c._rotation_trans_equations(c._parent_rotation_matrix, c.base_scalars()) == \
(-sin(q0) * c.y + cos(q0) * c.x, sin(q0) * c.x + cos(q0) * c.y, c.z)
assert c._rotation_trans_equations(c._inverse_rotation_matrix()) == \
assert c._rotation_trans_equations(c._inverse_rotation_matrix(), c.base_scalars()) == \
(sin(q0) * c.y + cos(q0) * c.x, -sin(q0) * c.x + cos(q0) * c.y, c.z)


def test_translation_trans_equations():
from sympy import symbols
q0 = symbols('q0')
a = CoordSys3D('a')
assert a._translation_trans_equations() == (a.x, a.y, a.z)
assert a._translation_trans_equations(a, a._origin, a.base_scalars()) == (a.x, a.y, a.z)
b = a.locate_new('b', None)
assert b._translation_trans_equations() == (b.x, b.y, b.z)
assert b._translation_trans_equations(inverse=True) == (b.x, b.y, b.z)
assert b._translation_trans_equations(a, b._origin, b.base_scalars()) == (b.x, b.y, b.z)
assert b._translation_trans_equations(a, b._origin, b.base_scalars(), inverse=True) == (b.x, b.y, b.z)
c = a.locate_new('c', (a.i + a.j + a.k))
assert c._translation_trans_equations() == (c.x + 1, c.y + 1, c.z + 1)
assert c._translation_trans_equations(a, c._origin, c.base_scalars()) ==\
(c.x + 1, c.y + 1, c.z + 1)
d = a.locate_new('d', (a.i + a.j + Vector.zero))
assert d._translation_trans_equations() == (d.x + 1, d.y + 1, d.z)
assert d._translation_trans_equations(inverse=True) == (d.x - 1, d.y - 1, d.z)
assert d._translation_trans_equations(a, d._origin, d.base_scalars()) ==\
(d.x + 1, d.y + 1, d.z)
assert d._translation_trans_equations(a, d._origin, d.base_scalars(), inverse=True) ==\
(d.x - 1, d.y - 1, d.z)