Blender Git Commit Log

Git Commits -> Revision 165e6db

Revision 165e6db by Mitchell Stokes (master)
August 11, 2011, 09:40 (GMT)
Adding a readonly length_squared property to mathutils.Vector. This is simply vector.dot(vector), so nothing new is really added, but it's nice for writing more intent revealing code. In other words:

if vec.dot(vec) > some_distance*some_distance:
do_something()

might not be quite as obvious looking as:

if vec.length_squared > some_distance*some_distance:
do_something()

As to why you'd want to use length_squared over length is that length uses a square root, which isn't always necessary for simple distance checks (e.g., closest object, checks like the ones above, ect).

Commit Details:

Full Hash: 165e6dbc07c4bf00fe492d4f65ea276a39628a85
SVN Revision: 39300
Parent Commit: 99caa94
Lines Changed: +16, -0

1 Modified Path:

/source/blender/python/mathutils/mathutils_Vector.c (+16, -0) (Diff)
By: Miika HämäläinenLast update: Nov-07-2014 14:18MiikaHweb | 2003-2021