# David Derwin

davidderwin

Expertise
Generalist
Location
United States of America
Website

## Recent Forum Posts

#### Resetting Object RotationApril 19, 2018, 3:42 p.m.

Using the VEX rotate function on a matrix will work to rotate around a given vector axis. I can't download your file at the moment but if you have a point or object at the origin then run this in a point wrangle:

```@N = {1,0,0};
v@side = normalize(cross(@N,{0,1,0}));
v@up = normalize(cross(@side,@N));

float angle = 45;

matrix rot = ident();

@N *= rot;
@up *= rot;
@side *= rot;
@P *= rot;
```

It will rotate however many degrees (45 degrees in this case) around the vector axis, which in the example above is @side ({0,0,1)}. It sounds like you have calculated the angles that each piece will need to be rotated so by using those angles and changing the vector axis as needed (rotating around x, y or z), this should be able to get your pieces rotated to the desired orientation.

#### python bounding box displayMay 12, 2017, 2:29 p.m.

I've found two ways you can call your geo into the hou.BoundingBox() class. If you plug your geo node into a python sop, you can call the BoundingBox class like this:

```node = hou.pwd()
geo = node.geometry()

bbox = geo.boundingBox()
print bbox

print "bbox minimum and maximum bounds: " + str(bbox)
print "bbox minvec: " + str(bbox.minvec())
print "bbox maxvec: " + str(bbox.minvec())
print "bbox size in each x,y,z axes: " + str(bbox.sizevec())
print "bbox center: " + str(bbox.center())
```

Or specify a sop directly, which wouldn't require having it plugged into the python sop.

```bboxnode = hou.node('../OUT')
bboxgeo = bboxnode.geometry()

bbox = bboxgeo.boundingBox()
```

I don't see a way for the class to automatically create a bounding box for you in the viewport, but it gives you the information required to do so.

geo.boundingBox() returns a type class ‘hou.BoundingBox’ so you cannot iterate the array directly to create points but you can get that information from minvec() and maxvec(), both of which return vectors. By combing the x, y and z values from min and max vec, you can construct the bounding box corners with points:

```# create points at bounding box corners:
a = bbox.minvec()
b = (bbox.minvec()[0], bbox.maxvec()[1], bbox.minvec()[2])
c = (bbox.maxvec()[0], bbox.maxvec()[1], bbox.minvec()[2])
d = (bbox.maxvec()[0], bbox.minvec()[1], bbox.minvec()[2])
e = bbox.maxvec()
f = (bbox.maxvec()[0], bbox.minvec()[1], bbox.maxvec()[2])
g = (bbox.minvec()[0], bbox.minvec()[1], bbox.maxvec()[2])
h = (bbox.minvec()[0], bbox.maxvec()[1], bbox.maxvec()[2])

corners = [a,b,c,d,e,f,g,h]

for position in corners:
point = geo.createPoint()
point.setPosition(position)
```

If you wanted to, you could then draw quads from the points as well, or create points the same way but from the other BoundingBox() methods, like center().

If your goal is to just create a bounding box for visualization in the viewport, you can plug your geometry into a box sop and it will create the box with the size of the bounding box of the input geometry.

I've attached a hip file which shows these different methods. I threw a transform below the test geo so you can see the bounding box react to changes in translation and rotation. Looks like both methods (python and box sop) don't create bounding boxes oriented to the geometry, which would have to be a different approach if that is your goal.

#### UVLayout without rotating UVsJuly 25, 2016, 5:11 p.m.

UVLayout is doing an excellent job laying out the UVs according to island area proportions, I'm looking for a way to restrict the UVs from being rotated when being packed, however. Maya has an option under UV Layout -> rotation -> none, which does what I'm after. Is there way to achieve this in Houdini 15.5? I see the Axis-Align Islands option but can't figure out what it does and it is not mentioned in the help document - is there a way to establish an axis direction through an attribute create perhaps? Any thoughts would be much appreciated Thanks!