Example #1
0
G = {}
G['V'] = []
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
Gs = []

# Ellipsoid Object
r = 10  # radius of cross section
a = 50  # radius of helix, must be big enough
b = 10  # pitch
t = [-80., 0., 50.]
degrees = 0
axis = [0, 1, 0]
q = aff.HH.rotation_quaternion(degrees, axis[0], axis[1], axis[2])
scale = 1.
s = [scale, scale, scale]  # the same scale as previous for caps
# n is length
H0 = he.Helix(r, a, b, t, q, s, m=10, n=20, N=10)
Gs = ext.Append(Gs, H0)
G = ext.GraphUnionS(G, H0)
#################################

# Save Scene 1
ext.Graphs2OBJ(BIGDATA + "Helix2.obj", Gs, "scene")

# Double-Click on OBJ file
import os
os.system(BIGDATA + "Helix2.obj")
Example #2
0
        G = ext.GraphUnionS(G,H2)

# floor
w,h,d = [500*2,500*2,5]
degrees = 0
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = 1.
s = [scale,scale,scale] # the same scale as previous for caps
t = [-w/2.,-h/2.,-d/2.-250]
#H3 = ext.CubeObj(w,h,d, t,q,s)
#Gs = ext.Append(Gs,H3)
#G = ext.GraphUnionS(G,H3)

# Save Scene 1
ext.Graphs2OBJ(BIGDATA+"WaterBottle.obj",Gs,"scene")
######################### SCENE 1 END

######################## SCENE 2 BEGIN
# Save CoffeeCup into new scene G,Gs to file
# "CoffeeCup.obj" as Scene 2
G = {}
G['V'] = []
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
Gs = []
# coffee cup
Hcc = CoffeeCup()
ext.Graph2OBJ(BIGDATA+"CoffeeCup.obj",Hcc,"scene")
        Gs = ext.Append(Gs,H2)
        G = ext.GraphUnionS(G,H2)

# floor
w,h,d = [500*2,500*2,5]
degrees = 0
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = 1.
s = [scale,scale,scale] # the same scale as previous for caps
t = [-w/2.,-h/2.,-d/2.-250]
#H3 = ext.CubeObj(w,h,d, t,q,s)
#Gs = ext.Append(Gs,H3)
#G = ext.GraphUnionS(G,H3)

ext.Graphs2OBJ("WaterBottle.obj",Gs,"scene")
f_ = open("WaterBottle.obj",'r')
txt = f_.read()
f_.close()
G_small = ext.OBJ2Graph(txt)

degrees = 0
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = .1
s = [scale,scale,scale] # the same scale as previous for caps
t = [0.,0.,0.]
pts = G_small['pts']
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
C = aff.Center(pts)
pts = aff.Translate(pts,-C[0],-C[1],-C[2],align=False)
Example #4
0
pts = aff.Translate(pts, -C[0], -C[1], -C[2], align=False)
pts = aff.Rotate(pts, q, align=False)
pts = aff.Scale(pts, s[0], s[1], s[2], align=False)
pts = aff.Translate(pts, t[0], t[1], t[2], align=False)
H1['pts'] = pts
Gs = ext.Append(Gs, H1)
G = ext.GraphUnionS(G, H1)

N = 10
degrees = 0
axis = [0, 1, 0]
qp = aff.HH.rotation_quaternion(degrees, axis[0], axis[1], axis[2])
scale = 1.
sp = [scale, scale, scale]  # the same scale as previous for caps
for i in range(N):
    Puma560.P, flag = Puma560.Reach(Puma560.P, goal)
    print(i, flag, Puma560.P.Start())
    G1 = Puma560.P.Graph()

    H2 = BodyGraph(G, Gs, G1, Puma560.P.pt, qp, sp)
    Gs = ext.Append(Gs, H2)
    G = ext.GraphUnionS(G, H2)
    if flag:
        break
# Save Scene 1
ext.Graphs2OBJ(BIGDATA + "Puma560-WaterBottle.obj", Gs, "scene")

# Double-Click on OBJ file
import os
os.system(BIGDATA + "Puma560-WaterBottle.obj")
Example #5
0
G['E'] = []
G['F'] = []
G['N'] = []
G['pts'] = []
Gs = []

# Ellipsoid Object
r = 3  # radius of cross section
ppath = [[0, 0, 0], [-10, 20, 0], [20, 30, 10], [30, 10, 20], [35, 5, 30],
         [40, 10, 20], [50, 30, 10], [70, 20, 20], [60, 0, 30], [55, 130, 40],
         [45, 120, 50], [35, 110, 45], [25, 110, 30], [20, 110, -25],
         [10, 130, -15], [10, 110, 0]]
t = [-80., 0., 50.]
degrees = 0
axis = [0, 1, 0]
q = aff.HH.rotation_quaternion(degrees, axis[0], axis[1], axis[2])
scale = 1.
s = [scale, scale, scale]  # the same scale as previous for caps
# n is length
H0 = wi.Wire(r, ppath, t, q, s, m=10, n=100)
Gs = ext.Append(Gs, H0)
G = ext.GraphUnionS(G, H0)
#################################

# Save Scene 1
ext.Graphs2OBJ(BIGDATA + "Wire1.obj", Gs, "scene")

# Double-Click on OBJ file
import os
os.system(BIGDATA + "Wire1.obj")
h = 20.
t = [50.,50.,50.]
degrees = 45
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = 1.
s = [scale,scale,scale] # the same scale as previous for caps
H1 = bs.Cone(r,h,t,q,s,m=20,n=20)
Gs = ext.Append(Gs,H1)
G = ext.GraphUnionS(G,H1)

# Cylinder Object
r = 10.
h = 40.
t = [-50.,50.,-50.]
degrees = 90
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = 1.
s = [scale,scale,scale] # the same scale as previous for caps
H1 = bs.Cylinder(r,h,t,q,s,m=20,n=20)
Gs = ext.Append(Gs,H1)
G = ext.GraphUnionS(G,H1)

# Save Scene 1
ext.Graphs2OBJ(BIGDATA+"BasicShapes-1.obj",Gs,"scene")

# Double-Click on OBJ file
import os
os.system(BIGDATA+"BasicShapes-1.obj")
Example #7
0
G['N'] = []
G['pts'] = []
Gs = []

# image to Elevation map. Image should have equal
# width and height so crop and resize.
im = cv2.imread("wavesource-b.jpg",0) # grayscale
blur = cv2.blur(im,(10,10))

m = 50
w,h,d = 100,100,1.

t = [-80.,0.,50.]
degrees = 0
axis = [0,1,0]
q = aff.HH.rotation_quaternion(degrees,axis[0],axis[1],axis[2])
scale = 1.
s = [scale,scale,scale] # the same scale as previous for caps
# n is length
H0 = em.ElevationMap(blur,w,h,d,t,q,s,m)
Gs = ext.Append(Gs,H0)
G = ext.GraphUnionS(G,H0)
#################################

# Save Scene 1
ext.Graphs2OBJ(BIGDATA+"ElevationMap1.obj",Gs,"scene")

# Double-Click on OBJ file
import os
os.system(BIGDATA+"ElevationMap1.obj")