Increasing vs Decreasing Interval and Transformation

i’m creating a box with random intervals and whenever i have a DECREASING Interval my translation doesn’t work properly. I guess i am missing a piece of information about transformations etc. can anybody help?

import Rhino as rh
import rhinoscriptsyntax as rs
import math
import random
import string

_bPoint = rh.Geometry.Point3d(0,0,0);
_zVec = rh.Geometry.Vector3d.ZAxis

_bPlane = rh.Geometry.Plane(_bPoint, _zVec);

intS = 100;

x1 = random.uniform(-intS,intS);
x2 = random.uniform(-intS,intS);
y1 = random.uniform(-intS,intS);
y2 = random.uniform(-intS,intS);
z1 = random.uniform(-intS,intS);
z2 = random.uniform(-intS,intS);

xS = rh.Geometry.Interval(x1,x2);
yS = rh.Geometry.Interval(y1,y2);
zS = rh.Geometry.Interval(z1,z2);

_cube = rh.Geometry.Box(_bPlane, xS, yS, zS);
_newCube = rh.Geometry.Box(_bPlane, xS, yS, zS);

trans = rh.Geometry.Transform.Translation(200,200,200);
rh.Geometry.Box.Transform(_newCube, trans);

a = _cube
b= _newCube

I guess this piece of code better shows what i’m trying to do/ have difficulties getting desired effects. Whenever _sA is a minus value translation won’t be performed - boxes will overlap.cubesOVerl cubesTrans

_sA = 100;

_bPoint = rh.Geometry.Point3d(0,0,0);
_zVec = rh.Geometry.Vector3d.ZAxis
_plane = rh.Geometry.Plane(_bPoint, _zVec);
_a = rh.Geometry.Interval(-_sA, _sA);

_box1 = rh.Geometry.Box(_plane, _a,_a,_a);

_box2 = rh.Geometry.Box.Clone(_box1);
a = _box1
b = _box2

_tV = rh.Geometry.Transform.Translation(200,0,0);

rh.Geometry.Box.Transform(_box2, _tV);


Can you tell what is not working with the translation.
I think with a decreasing interval your box will be positioned to the left/front/bottom and as such be in a different position as you expect?

maybe you want to sort the x1,x2 y1,y2 z1,z2 before creating the intervals to ensure an increasing interval?


The box just stays in place no matter what values the translation vector has. So i assume there has to be a special way of constructing a transformation matrix for decreasing intervals?

sorting the values might be a good idea but this is a part of a larger algorithm and i’m not quite sure yet if i would want it that way. however i will give it a thought. thanks! anyways i would wanna know if there’s a way of translating a cube with decreasing interval or if it really has to be constructed with increasing intervals.

A Rhino.Geometry.Box object is only valid if it has increasing intervals.

– Dale

1 Like