Beispiel #1
0
#

#
#  A test of intersection of three orthogonal cylinders.
#
#                                Gershon Elber, April 94.
#

save_mat = irit.GetViewMatrix()
save_res = irit.GetResolution()

length = 0.7
radius = 0.2
irit.SetResolution(40)

c1 = irit.cylin(((-length) / 2, 0, 0), (length, 0, 0), radius, 3)
c2 = irit.cylin((0, (-length) / 2, 0), (0, length, 0), radius, 3)
c3 = irit.cylin((0, 0, (-length) / 2), (0, 0, length), radius, 3)

irit.attrib(c1, "width", irit.GenRealObject(0.0001))
irit.attrib(c2, "width", irit.GenRealObject(0.0001))
irit.attrib(c3, "width", irit.GenRealObject(0.0001))

c12 = c1 * c2
c123 = c12 * c3
irit.attrib(c123, "width", irit.GenRealObject(0.005))
irit.color(c123, irit.RED)
irit.adwidth(c123, 3)

all = irit.list(c123, c1, c2, c3)
Beispiel #2
0
#                                                Gershon Elber, Apr 89
# 

t = irit.time( 1 )

save_res = irit.GetResolution()

#  Number of samples per circle:
irit.SetResolution(  8)

#  Note angle must be power of 2 as we multiply it by 2 each iteration, and
#  angle_log should hold the base 2 log of the divider in angle: log2 16 = 4.
angle = 360/16.0
angle_log = 4

c = irit.cylin( ( 0.6, 0, (-0.1 ) ), ( 0, 0, 0.3 ), 0.1, 0 )
irit.view( irit.list( c, irit.GetAxes() ), irit.ON )

i = 1
while ( i <= angle_log ):
    c = c ^ ( c * irit.rotz( angle ) )
    angle = angle * 2
    irit.view( irit.list( c, irit.GetAxes() ), irit.ON )
    i = i + 1

# 
#  Now lets create the wheel, make a hole in it to make it looks more real,
#  and subtract all the teeth from it:
# 

irit.SetResolution(  32)
save_res = irit.GetResolution()
save_view = irit.GetViewMatrix()

irit.SetViewMatrix(  irit.GetViewMatrix() * \
					 irit.scale( ( 0.6, 0.6, 0.6 ) ) * \
					 irit.rotx( 20 ) * \
					 irit.roty( 45 ) * \
					 irit.trans( ( (-0.3 ), 0.2, 0 ) ))

irit.SetResolution(  16)
s1 = irit.sphere( ( 0, 0, 0 ), 0.2 )
s2 = irit.sphere( ( 1, 0, 0 ), 0.2 )

irit.SetResolution(  8)
c1 = irit.cylin( ( 0, 0, 0 ), ( 1, 0, 0 ), 0.05, 3 )

irit.view( irit.list( irit.GetViewMatrix(), s1, s2, c1 ), irit.ON )

b1 = ( (s1 ^ s2) + c1 )
irit.free( s1 )
irit.free( s2 )
irit.free( c1 )
b2 = b1 * irit.trans( ( 0, 1, 0 ) )

irit.view( irit.list( b1, b2 ), irit.ON )

c2 = irit.cylin( ( 0, 0, 0 ), ( 0, 1, 0 ), 0.05, 3 )
c3 = irit.cylin( ( 1, 0, 0 ), ( 0, 1, 0 ), 0.05, 3 )

b12 = ( (b1 ^ b2) + (c2 ^ c3) )
Beispiel #4
0
#

#
#  Yet another simple 3D mechanical object.
#
#                                Created by Gershon Elber,       Sep 89
#

save_mat = irit.GetViewMatrix()
save_res = irit.GetResolution()

irit.SetResolution(16)
irit.SetViewMatrix(irit.GetViewMatrix() * irit.trans(
    (0, (-0.3), 0)) * irit.scale((0.8, 0.8, 0.8)))
b1 = irit.box(((-0.6), (-0.3), 0), 1.2, 0.6, 0.6)
c1 = irit.cylin((0, (-0.25), 0.59), (0, 0.5, 0), 0.55, 3)
s1 = (b1 + c1)
irit.color(s1, irit.YELLOW)
irit.free(b1)
irit.free(c1)
irit.view(irit.list(irit.GetViewMatrix(), s1), irit.ON)

b2 = irit.box(((-0.4), (-0.4), (-0.1)), 0.8, 0.8, 0.35)
irit.view(b2, irit.OFF)
s2 = (s1 - b2)
irit.free(s1)
irit.free(b2)
irit.color(s2, irit.YELLOW)
irit.view(s2, irit.ON)

c2 = irit.cylin((0, (-0.4), 0.595), (0, 0.8, 0), 0.3, 3)
Beispiel #5
0
button = irit.coerce( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ), \
                                                   irit.ctlpt( irit.E3, 2, 0, 0 ), \
                                                   irit.ctlpt( irit.E3, 3, 0, 0 ), \
                                                   irit.ctlpt( irit.E3, 3, 1.4, 0 ), \
                                                   irit.ctlpt( irit.E3, 2, 1.4, 0 ), \
                                                   irit.ctlpt( irit.E3, 0, 1.4, 0 ), \
                                                   irit.ctlpt( irit.E3, (-1 ), 1.4, 0 ), \
                                                   irit.ctlpt( irit.E3, (-1 ), 0, 0 ) ), irit.list( irit.KV_PERIODIC ) ), irit.KV_OPEN ) * irit.tx( (-1 ) ) * irit.ty( (-0.7 ) )
button = irit.sfromcrvs(
    irit.list(button * irit.tz((-1)), button, button * irit.tz(0.6),
              button * irit.sx(0.7) * irit.sy(0.001) * irit.tz(0.6)), 3,
    irit.KV_OPEN) * irit.sc(0.1)
irit.attrib(button, "rgb", irit.GenStrObject("155,155,155"))

redbutton = irit.cylin((0, 0, 0), (0, 0, 0.1), 0.1, 3)
irit.attrib(redbutton, "rgb", irit.GenStrObject("255,0,0"))

greenbutton = irit.cylin((0, 0, 0), (0, 0, 0.1), 0.075, 3)
irit.attrib(greenbutton, "rgb", irit.GenStrObject("0,255,0"))

buttons = irit.list(
    button * irit.rx(8) * irit.ty((-0.5)) * irit.tx(0.3) * irit.tz(7.55),
    button * irit.rx(8) * irit.ty((-0.5)) * irit.tx(0.75) * irit.tz(7.55),
    button * irit.rx(8) * irit.ty((-0.5)) * irit.tx(1.25) * irit.tz(7.55),
    button * irit.rx(8) * irit.ty((-0.5)) * irit.tx(1.7) * irit.tz(7.55),
    redbutton * irit.rx(8) * irit.tx(0.2) * irit.tz(7.55),
    greenbutton * irit.rx(8) * irit.tx(1.8) * irit.tz(7.55))
irit.free(button)
irit.free(redbutton)
irit.free(greenbutton)
        i = i + 1
    return retval


# ############################################################################
#
#  A non complete intersection between polyhedra.
#
v1 = (0, 0, 0)
v2 = (1, 0, 0)
v3 = (1, 1, 0)
v4 = (0, 1, 0)

p = irit.poly(irit.list(v1, v2, v3, v4), irit.FALSE)

c = irit.cylin((0.1, 0.5, (-0.5)), (0, 0, 1), 0.3, 3)

#
#  Boolean operation will fail here since the intersection is NOT CLOSED.
#  One is only able to extract the itersection curves then.
#
#  Cntrs = P + C;
#

intrcrv = irit.iritstate("intercrv", irit.GenRealObject(1))
cntrs = (p + c)
irit.attrib(cntrs, "dwidth", irit.GenRealObject(3))
irit.color(cntrs, irit.RED)
irit.interact(irit.list(c, p, cntrs))

irit.free(c)
Beispiel #7
0
                                  irit.ctlpt( irit.E3, 0.04, 0, 1.1 ), \
                                  irit.ctlpt( irit.E3, 0.04, 0, 1.25 ), \
                                  irit.ctlpt( irit.E3, 0.04, 0, 1.3 ), \
                                  irit.ctlpt( irit.E3, 0.001, 0, 1.3 ) ), irit.list( 0, 0, 0, 1, 2, 3,\
4, 4, 4 ) )
t1 = irit.surfrev( t1 )

t2 = t1 * irit.rotx( 180 )
t = irit.gpolygon( irit.list( t1, t2 ), 1 )
irit.free( t1 )
irit.free( t2 )
irit.interact( irit.list( irit.GetViewMatrix(), t ) )

irit.SetResolution(  20)

t3 = irit.cylin( ( 0, 0, (-2 ) ), ( 0, 0, 4 ), 0.1, 3 )
irit.view( t3, irit.OFF )

s1 = t3 * t
irit.free( t )
irit.free( t3 )

final = irit.convex( s1 )
irit.free( s1 )

irit.printf( "total time = %f\n", irit.list( irit.time( 0 ) ) )
#  In Seconds

irit.interact( final )
irit.save( "solid5", final )
irit.free( final )
irit.attrib(item9, "animation", mov_z)
irit.free(mov_z)

all = irit.list( item1, item2, item3, item4, item5, item6,\
item7, item8, item9 )
irit.interact(all)
irit.save("puz5anim", all)

# ############################################################################
#  Stairs prisms
#

len = 0.3

item1aux1 = irit.box((0, 0, 0), len, len, len)
item1aux2 = irit.cylin(((-len), 0, 0), (len * 2, 0, 0), len / 4 - 0.001, 3)
item1 = irit.list(item1aux1 * irit.tx(len * 0.5) +
                  item1aux2 * irit.ty(len * 3 / 4) * irit.tz(len * 3 / 4) +
                  item1aux1 * irit.tx((-len) * 1.5)) * irit.ty(
                      len / 2) * irit.tz((-len) / 2)
irit.color(item1, irit.CYAN)
irit.attrib(item1, "rgb", irit.GenStrObject("0, 255, 255"))
irit.free(item1aux1)
irit.free(item1aux2)

item2aux = irit.box(((-len) * 1.5, 0, 0), len * 3, len, len)
item2 = (item2aux - irit.box(
    ((-len) * 0.5, len / 2, (-len)), len, len * 3, len * 3)) * irit.rx(
        (-90)) * irit.tz(len / 2) * irit.ty((-len) * 1.5)
irit.color(item2, irit.CYAN)
irit.attrib(item2, "rgb", irit.GenStrObject("50, 255, 150"))
import irit
#

#
#  Intersection of cone and a cylinders ( more complex this time ):
#
#                        Created by Gershon Elber,       Sep. 89
#

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.2, 0.2, 0.2)))
save_res = irit.GetResolution()

irit.SetResolution(32)
cone1 = irit.cone((0, 0, (-1)), (0, 0, 4), 2, 1)
cylin1 = irit.cylin((0, 3, 0.3), (0, (-6), 0), 1, 3)
cube1 = irit.box(((-2), (-2), (-2)), 4, 4, 3.6)

s1 = (cone1 - cylin1) * cube1
irit.view(irit.list(irit.GetViewMatrix(), s1), irit.ON)
irit.free(cylin1)
irit.free(cone1)
irit.free(cube1)

irit.SetResolution(16)
cylin2 = irit.cylin((0, 0, (-2)), (0, 0, 6), 0.5, 3)
s2 = (s1 - cylin2)

irit.interact(s2)
irit.free(cylin2)
irit.free(s1)
Beispiel #10
0
import math
import irit
#


# 
#  Few simple test of disjoint booleans.
# 

# 
#  The inner sphere is disjoint to begin with;
# 

s1 = irit.sphere( ( 0, 0, 0 ), 1 ) ^ (-irit.sphere( ( 0, 0, 0 ), 0.7 ) )

c1 = irit.cylin( ( 0, 0, 0.8 ), ( 0, 0, 1 ), 0.2, 3 )

c2 = irit.cylin( ( 0, (-2 ), 0 ), ( 0, 4, 0 ), 0.5, 3 )

b1 = ( s1 + c1 + c1 * irit.rx( 180 ) )
b2 = ( b1 - c2 )

irit.interact( b2 )
irit.save( "disjnt1", b2 )

# 
#  The inner sphere is disjoint to begin with;
# 

s1 = irit.box( ( (-0.05 ), (-0.1 ), (-0.25 ) ), 0.1, 0.2, 0.5 )
s2 = ( s1 * irit.tx( (-1 ) ) ) ^ ( s1 * irit.tx( (-0.5 ) ) ) ^ ( s1 * irit.tx( 0 ) ) ^ ( s1 * irit.tx( 0.5 ) ) ^ ( s1 * irit.tx( 1 ) )
Beispiel #11
0
    irit.list(
        pillarsqr * irit.tx(1 - w) * irit.ty(1 - w) * irit.tz(0) * m1,
        pillarsqr * irit.tx(1 - w) * irit.ty(1 - w) * irit.tz((-w)) * m1,
        pillarsqr * m3 * irit.tx(1 - w) * irit.ty(1 - w) * irit.tz((-w)) * m2,
        pillarsqr * m3 * irit.tx(1 - w) * irit.ty(1 - w) * m2), 3,
    irit.KV_OPEN)

all = irit.list(basebot, basetop, pillar1, pillar2, pillar3, pillar4)
irit.interact(irit.list(all, view_mat1))

#
#  Escher's circular stairs,
#

irit.SetResolution(50)
cyl1 = (irit.cylin((0, 0, 0), (0, 0, 1), 0.5, 3) - irit.cylin(
    (0, 0, 0.5), (0, 0, 1), 0.4, 3))

b = irit.gbox((0.3, (-0.1), 0.9), (0.3, 0, 0), (0, 0.2, 0.02), (0, 0, 0.3))

i = 0
while (i <= 19):
    cyl1 = cyl1 - b * irit.rz(i * 360 / 20)
    i = i + 1

all = irit.list(cyl1) * irit.tz((-0.3))
irit.interact(irit.list(all, irit.GetViewMatrix()))
irit.free(cyl1)
irit.free(b)

# ############################################################################
Beispiel #12
0
def dup6faces( o ):
    retval = irit.list( o, o * irit.rz( 90 ), o * irit.rz( 180 ), o * irit.rz( 270 ), o * irit.rx( 90 ), o * irit.rx( (-90 ) ) )
    return retval
def boxwire(  ):
    retval = irit.list( irit.poly( irit.list(  ( (-1 ), (-1 ), (-1 ) ), irit.point( (-1 ), 1, (-1 ) ), irit.point( 1, 1, (-1 ) ), irit.point( 1, (-1 ), (-1 ) ), irit.point( (-1 ), (-1 ), (-1 ) ), irit.point( (-1 ), (-1 ), 1 ), irit.point( (-1 ), 1, 1 ), irit.point( 1, 1, 1 ), irit.point( 1, (-1 ), 1 ), irit.point( (-1 ), (-1 ), 1 ) ), 1 ), irit.poly( irit.list( irit.point( (-1 ), 1, (-1 ) ), irit.point( (-1 ), 1, 1 ) ), 1 ), irit.poly( irit.list( irit.point( 1, (-1 ), (-1 ) ), irit.point( 1, (-1 ), 1 ) ), 1 ), irit.poly( irit.list( irit.point( 1, 1, (-1 ) ), irit.point( 1, 1, 1 ) ), 1 ) )

    return retval
bw = boxwire(  )
irit.attrib( bw, "rgb", irit.GenStrObject("50, 50, 50") )

# ############################################################################

x = irit.box( ( (-1 ), (-1 ), (-1 ) ), 2, 2, 2 )

irit.SetResolution(  64)
c1 = irit.cylin( ( 0, 0, 2 ), ( 0, 0, (-4 ) ), 1.001, 0 )
c2 = c1 * irit.ry( 90 )
c3 = c1 * irit.rx( 90 )

x1 = x * c1 * (c2 * irit.sc( 1.0001 )) * (c3 * irit.sc( 0.9999 ))
irit.color( x1, irit.GREEN )

x2 = ( x - c1 - c2 - c3 )
x2c = clipxyz( x2 )
irit.color( x2c, irit.RED )

x3 = ( x * c3 * c2 * irit.sc( 1.0001 ) - c1 * irit.sc( 0.9999 ) )
x3c = clipxy( x3 )
irit.color( x3c, irit.YELLOW )

x4 = ( x * c3 - c2 * irit.sc( 1.0001 ) - c1 * irit.sc( 0.9999 ) )
Beispiel #13
0
                                     irit.ctlpt( irit.E3, 0.7, 1.1, 0 ), \
                                     irit.ctlpt( irit.E3, 1.1, 0.6, 0 ), \
                                     irit.ctlpt( irit.E3, 1.1, 0.2, 0 ), \
                                     irit.ctlpt( irit.E3, 1, 0, 0 ) ), irit.list( irit.KV_PERIODIC ) ) * irit.rz( (-90 ) ) * irit.sc( 0.3 )
direc = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, (-1.2 ), 0, 0 ), \
                                     irit.ctlpt( irit.E3, 0, 0.24, 0 ), \
                                     irit.ctlpt( irit.E3, 1.2, 0, 0 ) ), irit.list( irit.KV_OPEN ) )

irit.SetResolution(res)
srf1 = irit.gpolygon((-irit.sweepsrf(irit.coerce(cross, irit.KV_OPEN), direc,
                                     irit.GenIntObject(0))), 1)
irit.free(cross)
irit.free(direc)

irit.SetResolution(res * 5)
cyl1 = irit.cylin((0, 0, (-1)), (0, 0, 2), 1.15, 3)

srf2 = srf1 * cyl1
irit.free(cyl1)

irit.SetResolution(res * 5)
cyl2 = irit.cylin((0, 0.2, (-1)), (0, 0, 2), 0.6, 3)

srf3 = srf1 * cyl2 * irit.sz(4) * irit.sx(0.9) * irit.ty((-0.15))
irit.free(srf1)
irit.free(cyl2)

srf4 = (srf2 - srf3)
irit.free(srf2)
irit.free(srf3)
Beispiel #14
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#


# 
#  Routines to test the boolean operations among geometric objects:
# 
#  Intersection between a box and a cylinder - make a hole in the box
# 
b = irit.box( ( (-3 ), (-2 ), (-1 ) ), 6, 4, 2 )
c = irit.cylin( ( 0, 0, (-4 ) ), ( 0, 0, 8 ), 1, 3 )

save_view = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.GetViewMatrix() * irit.scale( ( 0.1, 0.1, 0.1 ) ))

a1 = ( b + c )
irit.interact( irit.list( irit.GetViewMatrix(), a1 ) )

a2 = b * c
irit.interact( a2 )

a3 = ( b - c )
irit.interact( a3 )

c = ( irit.con2( ( 0, 0, 0 ), ( 0, 0, 28 ), 17, 12, 3 ) - irit.con2( ( 0, 0, (-1 ) ), ( 0, 0, 30 ), 14, 9, 3 ) )
a4 = ( c - irit.box( ( (-50 ), (-50 ), (-1 ) ), 100, 100, 28 ) )

irit.save( "closloop", irit.list( a1, a2, a3, a4 ) )
Beispiel #15
0
#
#  Yet another simple 3D mechanical object.
#
#                                Created by Gershon Elber,       Sep 89
#

t = irit.time(1)

save_mat = irit.GetViewMatrix()
save_res = irit.GetResolution()

irit.SetResolution(48)

b1 = irit.box(((-0.3), (-0.3), 0), 0.6, 0.6, 0.15)
c1 = irit.cylin((0, 0, 0.1), (0, 0, 0.65), 0.14, 3)
s1 = irit.sphere((0, 0, 0.65), 0.3)
obj = (b1 + c1 + s1)
irit.free(b1)
irit.free(c1)
irit.free(s1)
irit.interact(irit.list(irit.GetViewMatrix(), obj))

b2 = irit.box(((-0.1), (-0.4), 0.55), 0.2, 0.8, 0.5)
b3 = irit.gbox((0, (-0.35), 0.63), (0.5, 0, 0.5), ((-0.5), 0, 0.5),
               (0, 0.7, 0))
boxes = (b2 + b3)
irit.free(b2)
irit.free(b3)
irit.view(boxes, irit.OFF)
obj = (obj - boxes)
Beispiel #16
0
#  Display of all primitives of the system:
#  BOX, GBOX, CONE, CYLIN, SPHERE, TORUS
#
#                                Created by Gershon Elber,       Dec. 88
#

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.5, 0.5, 0.5)))
axes15 = irit.GetAxes() * irit.scale((1.5, 1.5, 1.5))

#
#  Create primitive as approximated integral polynomial surfaces.
#
save_prim_rat_srfs = irit.iritstate("primratsrfs", irit.GenRealObject(0))

cyls = irit.list(irit.cylin(((-0.8), 0, 0), ((-0.5), 0.3, 0.3), 0.3, 0),
                 irit.cylin((0.8, 0, 0), (0.8, 0, 0), 0.3, 1),
                 irit.cylin((0, (-0.8), 0), (0.1, (-0.5), 0.2), 0.3, 3),
                 irit.cylin((0, 0.8, 0), (0, 0.8, 0), 0.3, 2),
                 irit.cylin((0, 0, (-0.8)), (0.4, 0.2, (-0.5)), 0.3, 3),
                 irit.cylin((0, 0, 0.8), (0, 0, 0.8), 0.3, 1))
irit.color(cyls, irit.RED)

cones = irit.list(irit.cone(((-0.5), 0, 0), ((-0.5), 0, 0), 0.5, 0),
                  irit.cone((0.5, 0, 0), (0.5, 0, 0), 0.5, 1),
                  irit.cone((0, (-0.5), 0), (0, (-0.5), 0), 0.5, 1),
                  irit.cone((0, 0.5, 0), (0, 0.5, 0), 0.5, 0),
                  irit.cone((0, 0, (-0.5)), (0, 0, (-0.5)), 0.5, 1),
                  irit.cone((0, 0, 0.5), (0, 0, 0.5), 0.5, 1))
irit.color(cones, irit.RED)
Beispiel #17
0
def do_coplanars(a, b, fname):
    irit.interact(irit.list(a, b))
    c1 = (a + b)
    irit.interact(c1)
    c2 = a * b
    irit.interact(c2)
    c3 = (a - b)
    irit.interact(c3)
    c4 = (b - a)
    irit.interact(c4)
    irit.save(
        fname, irit.list(c1, c2 * irit.tx(4), c3 * irit.tx(8),
                         c4 * irit.tx(12)))


a = irit.cylin((0, 0, 0), (0, 0, 1), 1, 3)
b = irit.cylin((0.5, 0, 0), (0, 0, 1), 1, 3)
do_coplanars(a, b, "coplanr1")

a = irit.cylin((0, 0, 0), (0, 0, 1), 1, 3)
b = a * irit.scale((2, 0.5, 1))
do_coplanars(a, b, "coplanr2")

a = irit.box(((-2), (-2), 0), 4, 4, 1)
b = irit.cylin((0, 0, 0), (0, 0, 2), 1, 3)
do_coplanars(a, b, "coplanr3")

a = irit.box((0, 0, 0), 1, 1, 2)
b = irit.box((0, 0, 0), 2, 1, 1)
do_coplanars(a, b, "coplanr4")
Beispiel #18
0
        j = 0
        while ( j <= irit.SizeOf( p ) - 1 ):
            h = irit.pattrib( p, j, "hcurv", irit.nil(  ) )
            mean = mean + h
            n = n + 1
            j = j + 1
        i = i + 1
    retval = mean/float(n)
    return retval

# ############################################################################

irit.SetResolution( 30 )

b1 = irit.box( ( (-0.3 ), (-0.3 ), 0 ), 0.6, 0.6, 0.15 )
c1 = irit.cylin( ( 0, 0, 0.1 ), ( 0, 0, 0.65 ), 0.14, 3 )
s1 = irit.sphere( ( 0, 0, 0.65 ), 0.3 )
t1 = irit.torus( ( 0, 0, 0.7 ), ( 0, 0, 1 ), 0.3, 0.15 )

obj = irit.maxedgelen( irit.triangl( b1 + c1 + s1 - t1, 1 ), 0.1 )

irit.free( b1 )
irit.free( c1 )
irit.free( s1 )
irit.free( t1 )

crvtrobj = irit.pcrvtr( obj, 1, 0 )
irit.free( obj )

crvtrobjrgb = gauss2rgb( crvtrobj, 15 )
irit.interact( crvtrobjrgb )
Beispiel #19
0
        ((-0.1), (-0.2), (-0.1)))
irit.color(pl2, irit.MAGENTA)

i = 0
while (i <= 300 * speed):
    c = irit.pmorph(pl1, pl2, i / (300.0 * speed))
    irit.color(c, irit.YELLOW)
    irit.view(irit.list(pl1, pl2, c), irit.ON)
    i = i + 1

irit.snoc(irit.pmorph(pl1, pl2, 0.25) * irit.tx(0), output)
irit.pause()

# ############################################################################

pl1 = (irit.con2((0, 0, (-1)), (0, 0, 4), 2, 1, 3) - irit.cylin(
    (0, 3, 0.1), (0, (-6), 0), 0.7, 3)) * irit.sc(0.2) * irit.trans(
        (0.8, 0.1, (-0.2)))
irit.color(pl1, irit.RED)
pl2 = (irit.con2((0, 0, (-1)), (0, 0, 4), 2, 1, 3) - irit.cylin(
    (0, 3, 1.1), (0, (-6), 0), 0.7, 3)) * irit.sc(0.3) * irit.trans(
        ((-0.8), (-0.2), (-0.4)))
irit.color(pl2, irit.MAGENTA)

i = 0
while (i <= 300 * speed):
    c = irit.pmorph(pl1, pl2, i / (300.0 * speed))
    irit.color(c, irit.YELLOW)
    irit.view(irit.list(pl1, pl2, c), irit.ON)
    i = i + 1

irit.snoc(irit.pmorph(pl1, pl2, 0.75) * irit.tx(2), output)
Beispiel #20
0
v11 = (0.7, 0, 0.2)
v12 = (0.6, 0, 0.2)

cross = irit.poly( irit.list( v1, v2, v3, v4, v5, v6,\

v7, v8, v9, v10, v11, v12 ),\
0 )
irit.view(cross, irit.ON)

irit.SetResolution(40)
t1 = irit.surfrev(cross)
irit.free(cross)
irit.interact(t1)

irit.SetResolution(16)
t2 = irit.cylin(((-1), 0, 0), (2, 0, 0), 0.15, 3)
t3 = irit.cylin((0, (-1), 0), (0, 2, 0), 0.15, 3)
irit.view(irit.list(t2, t3), irit.OFF)

s1 = (t1 - t2 - t3)
irit.free(t1)
irit.free(t2)
irit.free(t3)

final = irit.convex(s1)
irit.free(s1)

irit.interact(final)

irit.save("solid6h", final)
irit.free(final)
Beispiel #21
0
    retval = irit.nil()
    i = 0
    while (i <= irit.SizeOf(obj) - 1):
        p = irit.coord(obj, i)
        if (irit.getattr(p, "id") == irit.GenRealObject(id)):
            irit.snoc(p, retval)
        i = i + 1
    retval = irit.mergepoly(retval)
    irit.attrib(retval, "rgb", irit.GenStrObject(rgb))
    return retval


#
#  Create the big cylinder ( no hole yet )
#
c1 = irit.cylin((0, 0, 0), (0, 0, 0.7), 0.2, 3)
irit.attrib(c1, "id", irit.GenRealObject(1))

#
#  And the small one ( including the torus & sphere cut
#
c2 = irit.cylin((1, 0, 0.05), (0, 0, 0.4), 0.15, 3)
irit.attrib(c2, "id", irit.GenRealObject(2))
irit.SetResolution(8)

t1 = irit.circpoly((0, 1, 0), (0.151, 0, 0.25), 0.03)
irit.SetResolution(16)
t2 = irit.surfrev(t1) * irit.trans((1, 0, 0))
irit.free(t1)
irit.attrib(t2, "id", irit.GenRealObject(3))
Beispiel #22
0
tv = irit.tfromsrfs(discs, 3, irit.KV_OPEN)
irit.attrib(tv, "transp", irit.GenRealObject(0.5))
#  view( list( irit.GetAxes(), Tv, Teapot ), 1 );

# ############################################################################
#
#  Let the Teapot and Spheres come out of the teapot...
#

irit.SetResolution(10)

s1 = irit.sphere((0.2, 0.2, 0.8), 0.18)
irit.color(s1, irit.YELLOW)
s2 = irit.sphere((0.75, 0.25, 0.16667), 0.12) * irit.sz(3)
irit.color(s2, irit.MAGENTA)
c1 = irit.maxedgelen( irit.triangl( irit.cylin( ( 0.15, 0.85, 0.01 ), ( 0, 0, 0.98 ), 0.1, 3 ), 1 ),\
0.2 )
irit.color(c1, irit.CYAN)
c2 = irit.maxedgelen( irit.triangl( irit.cylin( ( 0.85, 0.85, 0.01 ), ( 0, 0, 0.98 ), 0.1, 3 ), 1 ),\
0.2 )
irit.color(c2, irit.CYAN)

genie = irit.list( teapotorig * irit.sc( 0.15 ) * irit.ry( (-90 ) ) * irit.trans( ( 0.5, 0.4, 0.47 ) ), s1, s2, c1,\
c2 )

b = irit.box((0, 0, 0), 1, 1, 1)
irit.attrib(b, "transp", irit.GenRealObject(0.5))

irit.interact(irit.list(irit.GetAxes(), b, genie))

wgenie = warpobj(genie, tv)
Beispiel #23
0
irit.SetResolution(5)
x2 = irit.triangl(irit.sphere(((-1.4), 2.2, 5.3), 1.4), 1)

spfit = irit.list(irit.fitpmodel(x1, 1, 0.01, 100),
                  irit.fitpmodel(x1, 1, 1e-005, 100),
                  irit.fitpmodel(x2, 1, 0.01, 100),
                  irit.fitpmodel(x2, 1, 1e-006, 100))

#
#  A cylinder: returned is (Error, Xcntr, Ycntr, Zcntr,
#                                  Xdir, Ydir, Zdir, Radius)
#

irit.SetResolution(20)
x1 = irit.triangl(irit.cylin((1, 2, 3), (0, 0, 1), 0.3, 0), 1)
x1 = irit.maxedgelen(x1, 0.3)

irit.SetResolution(50)
x2 = irit.triangl(irit.cylin(((-1.1), 3.7, 0.1), (1, 2, 1), 0.23, 0), 1)
x2 = irit.maxedgelen(x2, 0.3)

cylfit = irit.list(irit.fitpmodel(x1, 2, 1e-006, 100),
                   irit.fitpmodel(x2, 2, 0.001, 100))

#
#  A cone: returned is (Error, Xapex, Yapex, Zapex, angle,
#                                     Xdir, Ydir, Zdir)
#
x1 = irit.maxedgelen( irit.triangl( irit.con2( ( 0, 0, 0 ), ( 0, 0, 1 ), 1, 2, 0 ),\
1 ), 0.3 )
Beispiel #24
0
#
#  Intersection of cone and a cylinder:
#  Try this one with resolution equal 20 - slower, but much nicer!
#
#                        Created by Gershon Elber,       Jan. 89
#

view_mat1 = irit.GetViewMatrix() * irit.sc(0.2)
save_res = irit.GetResolution()
irit.SetResolution(8)

# ############################################################################

cone1 = irit.con2((0, 0, (-1)), (0, 0, 4), 2, 1, 3)
cylin1 = irit.cylin((0, 3, 0), (0, (-6), 2), 0.7, 3)

a = (cone1 + cylin1)
irit.free(cylin1)
irit.free(cone1)
irit.interact(irit.list(view_mat1, a))

#
#  Currently variables can not be introduced in a loop (except the iteration
#  variable), so we prepare all variables in advance.
#
cntrs = irit.nil()
intrcrv = irit.iritstate("intercrv", irit.GenIntObject(1))
i = (-0.9)
while (i <= 2.9):
    p = irit.circpoly((0, 0, 1), (0, 0, i), 6)
Beispiel #25
0
save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.GetViewMatrix() * 
					 irit.scale( ( 0.13, 0.13, 0.13 ) ))
save_res = irit.GetResolution()

cplnr = irit.iritstate( "coplanar", irit.GenIntObject(1) )
#  Try 'irit.iritstate("coplanar", false);'

box1 = irit.box( ( 0, 0, 1 ), 7.8, 10.4, 1.6 )
# If the line below is uncommented, then the file fails at the first operation
# most other resolutions work without problem. This could be because
# coincidentally something approximates colinear when it is not, but in that
# case a resultion of 50 or 20 might do it, and do not.
# resolution = 10;
hole1 = irit.cylin( ( 1, 1, 2.601 ), ( 0, 0, (-1.6015 ) ), 0.3, 3 )
solid1 = ( box1 - hole1 )
irit.free( hole1 )
irit.free( box1 )
irit.view( irit.list( irit.GetViewMatrix(), solid1 ), irit.ON )

# resolution = 20;
hole2 = irit.cylin( ( 6.8, 1, 2.601 ), ( 0, 0, (-1.6015 ) ), 0.3, 3 )
solid2 = ( solid1 - hole2 )
irit.free( hole2 )
irit.free( solid1 )
irit.view( solid2, irit.ON )


hole3 = irit.cylin( ( 1.0, 9.4, 2.601), ( 0, 0, (-1.6015 ) ), 0.3, 3 )
solid3 = ( solid2 - hole3 )
Beispiel #26
0
#
#  This solid was taken from: Geometric Modeling,
#  by Michael E. Mortenson page 468, figure 10.34
#
#                                Created by Gershon Elber,       Feb 89
#
#    High resolution version. Do not try this on an IBM PC.
#

t = irit.time(1)

save_res = irit.GetResolution()

irit.SetResolution(32)
t1 = irit.cylin(((-1.1), 0, 0), (2.2, 0, 0), 0.2, 3)
t2 = irit.cylin(((-0.8), 0, 0), (0.05, 0, 0), 0.3, 3)
t3 = irit.cylin((0.8, 0, 0), ((-0.05), 0, 0), 0.3, 3)

s1 = (t1 + t2 + t3)
irit.free(t1)
irit.free(t2)
irit.free(t3)
s1 = irit.convex(s1)
irit.view(s1, irit.ON)

s2 = s1 * irit.roty(90)
s3 = s1 * irit.rotz(90)
irit.view(irit.list(s2, s3), irit.OFF)

s4 = (s1 + s2 + s3)
Beispiel #27
0
item6 = item1 * irit.rx(90) * irit.ry((-90))
irit.color(item6, irit.CYAN)

allitems = irit.list(item1, item2, item3, item4, item5, item6)
irit.interact(allitems)
irit.save("sixbrck2", allitems)

# ############################################################################
#  Rounded StickStar (No (dis)assembly).
#
eps = 0.05
irit.SetResolution(40)
rad = 0.3
len = (rad * 2 + eps) * 2
itemaux1 = irit.cylin((0, 0, (-len)), (0, 0, len * 2), rad, 3)
itemaux2 = (itemaux1 * irit.tx(rad) -
            itemaux1 * irit.rotx(90) * irit.sc(1 + eps) * irit.tz(rad) -
            itemaux1 * irit.rotx(90) * irit.sc(1 + eps) * irit.tz((-rad)))
diag = (len + eps)
diagpoly = irit.poly(
    irit.list((diag, diag, 0), ((-diag), diag, 0), ((-diag), 0, diag),
              (diag, 0, diag)), irit.FALSE)
item1 = (itemaux2 - diagpoly - diagpoly * irit.sy((-1)) - diagpoly * irit.sz(
    (-1)) - diagpoly * irit.sz((-1)) * irit.sy((-1)))
irit.color(item1, irit.RED)

item2 = item1 * irit.sx((-1))
irit.color(item2, irit.MAGENTA)

item3 = item1 * irit.rx(90) * irit.rz(90)
Beispiel #28
0
save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.5, 0.5, 0.5)))
save_res = irit.GetResolution()

#
#  Try it with coplanar false for fun.
#
#  irit.iritstate( "coplanar", false );
#

psort = irit.iritstate("polysort", irit.GenRealObject(0))

t1 = irit.box(((-2), (-0.35), 0), 4, 0.7, 0.4)
irit.SetResolution(80)
t2 = irit.cylin((0, 0, 0), (0, 0, 0.4), 1.4, 3)
s1 = t1 * t2
irit.free(t1)
irit.free(t2)
irit.view(irit.list(irit.GetViewMatrix(), s1), irit.ON)

irit.SetResolution(40)
t3 = irit.cylin((0, 0, 0), (0, 0, 0.4), 0.9, 3)
s2 = (s1 + t3)
irit.free(t3)
irit.free(s1)
irit.view(s2, irit.ON)

irit.SetResolution(80)
t4 = irit.cylin((1.45, (-0.5), 1), (0, 1, 0), 0.8, 3)
t5 = irit.cylin(((-1.45), (-0.5), 1), (0, 1, 0), 0.8, 3)
Beispiel #29
0
# 
#  The Logo of the Technion
# 
#                                Gershon Elber, March 1998
# 

save_res = irit.GetResolution()

tech1 = irit.poly( irit.list( ( 0, (-0.35 ), 0 ), ( 0.58, 0.8, 0 ), ( (-0.58 ), 0.8, 0 ), ( 0, (-0.35 ), 0 ) ), irit.FALSE )
tech1clip = irit.extrude( tech1, ( 0, 0, 1 ), 3 ) * irit.tz( (-0.5 ) ) * irit.ty( (-0.06 ) )

angle = 360/16.0
angle_log = 4
irit.SetResolution(  16)
c = irit.cylin( ( 0.6, 0, (-0.1 ) ), ( 0, 0, 0.3 ), 0.1, 3 )
i = 1
while ( i <= angle_log ):
    c = c ^ ( c * irit.rotz( angle ) )
    angle = angle * 2
    i = i + 1

irit.SetResolution(  64)
w = irit.cylin( ( 0, 0, 0 ), ( 0, 0, 0.12 ), 0.6, 3 )

wheel = ( w * irit.rz( 360/32.0 ) - c - tech1clip - irit.cylin( ( 0, 0, (-0.2 ) ), ( 0, 0, 0.5 ), 0.35, 3 ) )

irit.free( c )
irit.free( w )

#