Ask Your Question
2

Accessing component of 3D vector?

asked 2019-05-25 11:46:45 -0500

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
2

answered 2019-05-26 13:25:34 -0500

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 11:46:45 -0500

Seen: 59 times

Last updated: May 26