Ask Your Question
1

Basic vector functions in Sage

asked 2012-04-25 07:43:34 +0100

paldepind gravatar image

updated 2015-01-14 11:00:17 +0100

FrédéricC gravatar image

Isn't there any inbuilt 3D vector functions in Sage?

For instance like a function to get the dot product, cross product or angle between two vectors? Or functions to get the distance from a point to a line? Find the intersections between two lines? Having such functions would be a great help and would greatly increase the speed of my workflow in school.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2012-04-25 13:08:39 +0100

kcrisman gravatar image

These are all accessible using the "dot" object-oriented notation. See, for example, this documentation, from which this example stems.

sage: v = vector([1,2,3]); w = vector([0,5,-9])
sage: v.cross_product(v)
(0, 0, 0)
sage: u = v.cross_product(w); u
(-33, 9, 5)
sage: u.dot_product(v)
0
sage: u.dot_product(w)
0
edit flag offensive delete link more

Comments

I only see cross product and dot product? What about the other things I mentioned? And for instance the distance from a point to a plane? I can't find any of it by searching.

paldepind gravatar imagepaldepind ( 2012-05-01 13:03:47 +0100 )edit

I don't think that Sage would include things that one is supposed to do mathematics for. The intersection of two lines would depend greatly on how you represented them, for instance - parametric, as an intersection of planes, as a formula in 2D... Same thing with an angle, which you can get from the cross *or* dot product with inverse trig functions. Of course, many of these would be relatively easy to implement, and we would welcome the addition.

kcrisman gravatar imagekcrisman ( 2012-05-01 22:36:21 +0100 )edit

Thanks for the explanation. How can I implement these functions in Sage? At least for my own usage.

paldepind gravatar imagepaldepind ( 2012-05-03 05:42:27 +0100 )edit

Depends on what you want. For your own usage, you could put the code for such a thing in a .sage file and then have loading that file done automatically by an init.sage file (search for this). For wider distribution, see http://www.sagemath.org/doc/developer/walk_through.html for how to start contributing to Sage directly, or you could just upload code for an algorithm to a ticket you created on http://trac.sagemath.org/sage_trac/.

kcrisman gravatar imagekcrisman ( 2012-05-03 10:36:22 +0100 )edit

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: 2012-04-25 07:43:34 +0100

Seen: 28,983 times

Last updated: Apr 25 '12