How to use the vector.Vec3d function in vector

To help you get started, weβve selected a few vector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

seung-lab / znn-release / python / refactoring / box.py View on Github
def max(self):
"""Return the max corner as a vector."""
return Vec3d(self._max)
seung-lab / znn-release / python / refactoring / box.py View on Github
def testExpand(self):
b1 = Box(Vec3d(1,1,1),[2,2,2])
b1.expand_by(1)
self.assertTrue(b1 == Box((0,0,0),(3,3,3)))
b1.expand_by((-1,0,0))
self.assertTrue(b1 == Box((1,0,0),(2,3,3)))
seung-lab / znn-release / python / refactoring / box.py View on Github
def __init__(self, v1_or_box, v2=None):
"""Initialize a box from another box or two vectors."""
if v2 == None:
self.set_coords(v1_or_box.min(), v1_or_box.max())
else:
self.set_coords(Vec3d(v1_or_box), Vec3d(v2))
seung-lab / znn-release / python / refactoring / box.py View on Github
def centered_box(c, s):
"""Return a box of size s centered on c."""
center = Vec3d(c)
size   = Vec3d(s)
half   = size/2
assert size.x >= 0 and size.y >= 0 and size.z >= 0
v1 = center - half
v2 = v1 + size
return Box(v1,v2)
seung-lab / znn-release / python / refactoring / tensor.py View on Github
def _set_offset(self, offset):
"""
Set an offset from origin.
"""
self._offset = Vec3d(offset)

# update bounding box & range
self._set_bounding_box()
self._set_range()
seung-lab / znn-release / python / refactoring / box.py View on Github
def testMerge(self):
b1 = Box(Vec3d(1,1,1),[2,2,2])
b2 = Box(Vec3d(3,3,3),[2,2,2])
b3 = b1.merge(b2)
self.assertTrue(b3 == Box((1,1,1),(3,3,3)))
b4 = b3.merge(Box((0,0,0),(-1,-1,-1)))
self.assertTrue(b4 == Box((-1,-1,-1),(3,3,3)))
seung-lab / znn-release / python / refactoring / box.py View on Github
def testContains(self):
b = Box(Vec3d(1,1,1),[3,3,3])
self.assertTrue(b.contains(b.min()))
self.assertTrue(not b.contains(b.max()))
self.assertTrue(b.contains((2,2,2)))
self.assertTrue(not b.contains((-2,-2,-2)))
seung-lab / znn-release / python / refactoring / box.py View on Github
def contains(self, v):
"""Return true if a point is inside the box."""
(x,y,z) = Vec3d(v)
return (self._min.x &lt;= x &lt; self._max.x and
self._min.y &lt;= y &lt; self._max.y and
self._min.z &lt;= z &lt; self._max.z)
seung-lab / znn-release / python / refactoring / box.py View on Github
def testCreationAndAccess(self):
b = Box((1,1,1),[2,2,2])
self.assertTrue(b.min()  == Vec3d(1,1,1))
self.assertTrue(b.max()  == Vec3d(2,2,2))
self.assertTrue(b.size() == Vec3d(1,1,1))
b = Box((1,0,1),[0,1,0])
self.assertTrue(b.min()  == Vec3d(0,0,0))
self.assertTrue(b.max()  == Vec3d(1,1,1))
self.assertTrue(b.size() == Vec3d(1,1,1))
b1 = Box(b)
self.assertTrue(b1.min()  == Vec3d(0,0,0))
self.assertTrue(b1.max()  == Vec3d(1,1,1))
self.assertTrue(b1.size() == Vec3d(1,1,1))

vector

Vector classes and utilities

BSD-3-Clause