Ask Your Question
0

Point -> Vector to a point

asked 2019-04-07 00:10:33 +0200

thetha gravatar image

updated 2020-06-26 14:57:24 +0200

FrédéricC gravatar image

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 flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-04-07 15:37:40 +0200

eric_g gravatar image

updated 2019-04-07 15:57:56 +0200

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...

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-04-07 00:10:33 +0200

Seen: 724 times

Last updated: Apr 07 '19