Ask Your Question
2

Accessing component of 3D vector?

asked 2019-05-25 18:46:45 +0100

etills gravatar image

So if you make a vector like this:

vector1 = arrow((0,0,0),(1,2,3))

and you want to access a component of the vector, for example the second y component (2), how would you do this? Something like vector1.y2 (that doesn't work haha) but how would I do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-05-26 20:25:34 +0100

tmonteil gravatar image

The object you are creating, is not really a vector, it is a plot object:

sage: type(vector1)
<class 'sage.plot.plot3d.base.TransformGroup'>

So, the best would be to work on genuine vectors:

sage: vector1 = vector((1, 2, 3))

You can access it second value with:

sage: vector1[1]
2

You can still plot it if you want:

sage: arrow((0,0,0), vector1)
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

Stats

Asked: 2019-05-25 18:46:45 +0100

Seen: 388 times

Last updated: May 26 '19