--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/c9e45103-82a5-49b1-acb0-260adeb579bfn%40googlegroups.com.
# HERE - Is there a less awkward way to evaluate the scalar field at a
# given vector?
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/dd7d4528-1cf6-9ca2-160d-0467efcd2f5a%40gmail.com.
Hello Ryan,# HERE - Is there a less awkward way to evaluate the scalar field at a
# given vector?Not that I'm aware of. I would have done the same intricate loop that you did.Note that you were "lucky": if your gp vector would have had at least one zero-component, then gp.components wouldnot contain the zero component, resulting in a KeyError which would have complicated things even further.
In [95]: dict(zip(R3.base_scalars(), g.to_matrix(R3)))
Out[95]:
⎧ 2 ⎫
⎨x_: t, y_: -t , z_: -t⎬
⎩ ⎭
Vector Module definitely needs to be polished a little further in order to become user-friendly. I fear this discussionmight get lost with time. I would suggest opening either an issue or a discussion suggesting improvements to thismodule, providing the aforementioned example. https://github.com/sympy/sympy/discussions
Conceptually this is a bit muddled though as it conflates vectors with points. Formally what is wanted here is to evaluate a scalar field at a point represented by a particular position vector wrt some reference frame. I don't know if the vector module has the concept of a point as opposed to a vector.
In [1]: import sympy
In [2]: import sympy.vector
In [3]: R3 = sympy.vector.CoordSys3D("R3")
In [4]: t = sympy.Symbol("t", real=True)
In [5]: g = t * R3.i - t**2 * R3.j - 0 * R3.k
In [6]: # Three different ways to get the components as a tuple:
In [7]: R3.origin.locate_new(‘P', g).express_coordinates(R3) # Using Point
Out[7]: (t, -t**2, 0)
In [8]: tuple(b.dot(g) for b in R3.base_vectors()) # dot product with each basis
Out[8]: (t, -t**2, 0)
In [9]: tuple(g.to_matrix(R3))
Out[9]: (t, -t**2, 0)
g.to_point(R3.origin).to_dict(R3)
R3.origin.locate_new(‘P', g).to_dict(R3)
--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/73A0AD28-CA29-4D87-923D-213355CDD1C6%40gmail.com.