# 2 sets of coordinates in EuclideanSpace?

Hello,

I would like to work with 2 vectors in EuclideanSpace each having x1,y1,z1 and x2,y2,z2 coordinates. I will be needing to switch back and forth between cartesian and spherical coordinates as well.

As an example, say, (r1,0,0) -> (x1,y1,z1) while (r2,0,0)->(x2,y2,z2) in the same EuclideanSpace.

How would one work with multiple vectors (with independent coordinates) in EuclideanSpace?

Should one define 2 chart for spherical coordinates and 2 for cartesian coordinates?

Or should one create 2 different EuclideanSpace and combine them (if possible)?

edit retag close merge delete

Sort by » oldest newest most voted

In EuclideanSpace, there are three predefined coordinate charts, which are returned by the methods cartesian_coordinates(), spherical_coordinates() and cylindrical_coordinates():

sage: E.<x,y,z> = EuclideanSpace()
sage: E.cartesian_coordinates()
Chart (E^3, (x, y, z))
sage: E.spherical_coordinates()
Chart (E^3, (r, th, ph))
sage: E.cylindrical_coordinates()
Chart (E^3, (rh, ph, z))


But you can define as many charts as you want by means of the method chart(). For instance:

sage: Cartes1.<x1, y1, z1> = E.chart()
sage: Cartes1
Chart (E^3, (x1, y1, z1))


To complete the construction, you have to specify the transition map from previously defined coordinates:

sage: Cartes_to_Cartes1 = E.cartesian_coordinates().transition_map(Cartes1, [x-2, y+3, z])
sage: Cartes_to_Cartes1.display()
x1 = x - 2
y1 = y + 3
z1 = z


as well as its inverse, either by asking Sage to compute it (method inverse()) or by specifying it by hand (method set_inverse()):

sage: Cartes_to_Cartes1.inverse().display()
x = x1 + 2
y = y1 - 3
z = z1


Then Sage can compute vector field components in the new coordinate frame:

sage: v = E.vector_field(x+z, y*z, x*y)
sage: v.display()
(x + z) e_x + y*z e_y + x*y e_z
sage: v.display(Cartes1)
(x1 + z1 + 2) d/dx1 + (y1 - 3)*z1 d/dy1 + ((x1 + 2)*y1 - 3*x1 - 6) d/dz1


For more details, see the coordinate chart documentation.

more

Thank you so much! this is really awesome. I love the way sagemath handle these things.

( 2021-01-30 23:43:42 +0100 )edit