# Point -> Vector to a point

Hello everyone,

If i have point in 3D

A=point3d((4,3,2),size=10,color='red',opacity=.5)


How to create a vector from the origin to the point. I know i could define the vector. But I would rather have a point, for plotting reasons

And i would like to plot the Point and the Vector, with automatic labeling of the coordinates.

I have managed to do this like:

from sage.plot.plot3d.shapes2 import frame3d
F=frame3d([0,0,0],vector([10,10,10]),color='red')
A=points((4,3,2),size=10,color='red',opacity=.5)
B=point([(4,3,8)],size=10,color='red',opacity=.5)

t = var('t')
p = vector([4,3,2])
q = vector([0,0,0])
vec=parametric_plot3d(p*t+q, (t,0,1))

#vectB=vector(B.xdata[1],B.ydata[1],B.zdata[1])
e=0.2
eps=vector([4+e,3+e,2+e])
T_A = text3d('A',eps)
#T_B = text3d('B',B)
F+A+T_A+B+vec


Is there any better, way to do it?

Here is the file: https://share.cocalc.com/share/a3f14e...

edit retag close merge delete

Sort by » oldest newest most voted

Like this:

E = EuclideanSpace(3)
A = E.point((4,3,2), name='A')
v = E.tangent_space(A)((1,2,1), name='v')  # a vector at A
A.plot(size=20, color='red', opacity=0.5) + v.plot(color='green')

• Remark 1: the command A = E.point((4,3,2), name='A') can be shorten to A = E((4,3,2), name='A') (this notation reflects SageMath's parent/element framework, points being elements of the Euclidean space E)
• Remark 2: the notation E.tangent_space(A)((1,2,1)) arises from differential geometry; it simply means the vector of components (1,2,1) whose origin is A.

For more details and examples see https://sagemanifolds.obspm.fr/vector...

more