...
 
Commits (3)
......@@ -9,6 +9,7 @@ class Joint:
class FingerJoint(Joint):
def go(self, face, edge):
inset = False
edgename = face.name + edge.name
index = face.edgeIndex(edge.name)
angle, flip = edge.faces[face]
......@@ -16,7 +17,9 @@ class FingerJoint(Joint):
thickness = self.kwargs["thickness"]
coords = face.edgeCoords(index)
length = face.edgeLength(index)
length = face.edgeLength(index)
if inset:
length -= thickness
pt1 = np.array(coords[0])
pt2 = np.array(coords[1])
......@@ -29,43 +32,65 @@ class FingerJoint(Joint):
flip = flip and (n % 2 == 1)
dpt = (pt2 - pt1) * 1. / n
dpt = (pt2 - pt1) * 1.0 * dt / face.edgeLength(index)
ppt = np.array((dpt[1], -dpt[0])) / dt
newEdges = []
newPts = []
oldPt = coords[0]
newPt = coords[0]
def addNew(newEdge, newPt):
newEdges.append(newEdge)
newPts.append(newPt)
newEdge.join(newEdge.length, face)
if inset:
# inset from the edge for 3 face corners
newPt = newPt - ppt * dln
newEdge = HyperEdge(edgename + "fjx1", dln)
addNew(newEdge, newPt)
newPt = newPt + dpt * thickness / dt / 2.0
newEdge = HyperEdge(edgename + "fjx2", dt)
addNew(newEdge, newPt)
newPt = newPt + ppt * dln
newEdge = HyperEdge(edgename + "fjx3", dln)
addNew(newEdge, newPt)
if flip:
newPt = coords[0] + ppt * dlp
newPt = newPt + ppt * dlp
newEdge = HyperEdge(edgename + "fj0", dlp)
else:
newPt = coords[0] - ppt * dln
newPt = newPt - ppt * dln
newEdge = HyperEdge(edgename + "fj0", dln)
for i in range(int(n)):
newEdges.append(newEdge)
newPts.append(newPt)
newEdge.join(newEdge.length, face)
addNew(newEdge, newPt)
oldPt = newPt
newPt = oldPt + dpt
newPt = newPt + dpt
newEdge = HyperEdge(edgename + "fjd%d" % i, dt)
newEdges.append(newEdge)
newPts.append(newPt)
newEdge.join(newEdge.length, face)
addNew(newEdge, newPt)
oldPt = newPt
if flip:
newPt = oldPt - ppt * dl
newPt = newPt - ppt * dl
else:
newPt = oldPt + ppt * dl
newPt = newPt + ppt * dl
newEdge = HyperEdge(edgename + "fjp%d" % i, dl)
flip = not flip
if flip:
newEdge = HyperEdge(edgename + "fjn", dln)
if not flip:
addNew(newEdge, newPt)
else:
newEdge = HyperEdge(edgename + "fjn", dlp)
newPt = newPt - ppt * dl
if inset:
newPt = newPt + dpt * thickness / dt / 2.0
newEdge = HyperEdge(edgename + "fjy", dt)
addNew(newEdge, newPt)
newEdge = HyperEdge(edgename + "fjn", dln)
newEdges.append(newEdge)
return newPts, newEdges
......@@ -13,7 +13,7 @@ c.addConstConstraint(("legl","flip"), 1)
c.addConstConstraint(("legr","flip"), 0)
c.addConstraint(("crossbar","l"), "width")
c.addConstraint(("crossbar","w"), ("height", "rocker"), "2 * x[0] * np.sin(np.deg2rad(x[1]))")
c.addConstraint(("crossbar","w"), ("height", "rocker"), "x[0] * np.sin(np.deg2rad(x[1]))")
c.addConnection(("seat","left"),("legl","topedge"), angle=0)
c.addConnection(("seat","right"),("legr","topedge"), angle=0)
......
......@@ -11,25 +11,30 @@ c.addParameter("thickness", 10, paramtype="length")
c.addParameter("rocker", 10, paramtype="angle")
c.addParameter("flip", 0, paramtype="boolean")
n = 6
l = [
["depth"],
(("height", "rocker", "flip"), "2 * x[0] * np.sin(np.deg2rad(x[1] * x[2]))"),
(("height", "rocker", "flip"), "1 * x[0] * np.sin(np.deg2rad(x[1] * x[2]))"),
(("height", "rocker", "flip"), "1 * x[0] * np.sin(np.deg2rad(x[1] * x[2]))"),
["height"],
["depth"],
["height"],
(("height", "rocker", "flip"), "2 * x[0] * np.sin(np.deg2rad(x[1] * (1-x[2])))")
(("height", "rocker", "flip"), "1 * x[0] * np.sin(np.deg2rad(x[1] * (1-x[2])))"),
(("height", "rocker", "flip"), "1 * x[0] * np.sin(np.deg2rad(x[1] * (1-x[2])))"),
]
a = [
[["rocker", "flip"], "x[0] * x[1]"],
0,
(["rocker", "flip"], "90+(x[0] * x[1])"),
[["rocker", "flip"], "90-(x[0]*2 * x[1])"],
[["rocker", "flip"], "90-(x[0]*2 * (1-x[1]))"],
(["rocker", "flip"], "90+(x[0] * (1-x[1]))"),
[["rocker", "flip"], "x[0] * (1 - x[1])"]
0,
[["rocker", "flip"], "x[0] * (1 - x[1])"],
]
n = len(l)
for i in range(n):
c.addSubcomponent("beam%d" % i, "Rectangle")
c.addSubcomponent("kite%d" % i, "Kite", inherit="thickness", prefix=None)
......@@ -45,8 +50,8 @@ for i in range(n):
c.addConnection(("beam%d" % i,"b"),("kite%d" % ((i - 1) % n),"t"), angle=0)
c.inheritInterface("topedge", ("beam3", "r"))
c.inheritInterface("crossbar", ("beam5", "l"))
c.inheritInterface("topedge", ("beam4", "r"))
c.inheritInterface("crossbar", ("beam7", "l"))
c.inheritInterface("crossbarflip", ("beam1", "l"))
c.toYaml("library/RockerLeg.yaml")
......@@ -34,7 +34,7 @@ subcomponents:
parameters:
l: {parameter: width}
w:
function: 2 * x[0] * np.sin(np.deg2rad(x[1]))
function: x[0] * np.sin(np.deg2rad(x[1]))
parameter: [height, rocker]
legl:
classname: RockerLeg
......
......@@ -5,7 +5,7 @@ connections:
- {angle: 0}
connection1:
- [beam0, b]
- [kite5, t]
- [kite7, t]
- {angle: 0}
connection10:
- [beam5, t]
......@@ -15,6 +15,22 @@ connections:
- [beam5, b]
- [kite4, t]
- {angle: 0}
connection12:
- [beam6, t]
- [kite6, b]
- {angle: 0}
connection13:
- [beam6, b]
- [kite5, t]
- {angle: 0}
connection14:
- [beam7, t]
- [kite7, b]
- {angle: 0}
connection15:
- [beam7, b]
- [kite6, t]
- {angle: 0}
connection2:
- [beam1, t]
- [kite1, b]
......@@ -48,9 +64,9 @@ connections:
- [kite3, t]
- {angle: 0}
interfaces:
crossbar: {interface: l, subcomponent: beam5}
crossbar: {interface: l, subcomponent: beam7}
crossbarflip: {interface: l, subcomponent: beam1}
topedge: {interface: r, subcomponent: beam3}
topedge: {interface: r, subcomponent: beam4}
metadata:
depth: {default: 50, paramtype: length}
flip: {default: 0, paramtype: boolean}
......@@ -71,33 +87,49 @@ subcomponents:
parameters:
l: {parameter: thickness}
w:
function: 2 * x[0] * np.sin(np.deg2rad(x[1] * x[2]))
function: 1 * x[0] * np.sin(np.deg2rad(x[1] * x[2]))
parameter: [height, rocker, flip]
beam2:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: thickness}
w: {parameter: height}
w:
function: 1 * x[0] * np.sin(np.deg2rad(x[1] * x[2]))
parameter: [height, rocker, flip]
beam3:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: thickness}
w: {parameter: depth}
w: {parameter: height}
beam4:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: thickness}
w: {parameter: height}
w: {parameter: depth}
beam5:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: thickness}
w: {parameter: height}
beam6:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: thickness}
w:
function: 1 * x[0] * np.sin(np.deg2rad(x[1] * (1-x[2])))
parameter: [height, rocker, flip]
beam7:
classname: Rectangle
kwargs: {}
parameters:
l: {parameter: thickness}
w:
function: 2 * x[0] * np.sin(np.deg2rad(x[1] * (1-x[2])))
function: 1 * x[0] * np.sin(np.deg2rad(x[1] * (1-x[2])))
parameter: [height, rocker, flip]
kite0:
classname: Kite
......@@ -111,11 +143,17 @@ subcomponents:
classname: Kite
kwargs: {}
parameters:
angle: 0
thickness: {parameter: thickness}
kite2:
classname: Kite
kwargs: {}
parameters:
angle:
function: 90+(x[0] * x[1])
parameter: [rocker, flip]
thickness: {parameter: thickness}
kite2:
kite3:
classname: Kite
kwargs: {}
parameters:
......@@ -123,7 +161,7 @@ subcomponents:
function: 90-(x[0]*2 * x[1])
parameter: [rocker, flip]
thickness: {parameter: thickness}
kite3:
kite4:
classname: Kite
kwargs: {}
parameters:
......@@ -131,7 +169,7 @@ subcomponents:
function: 90-(x[0]*2 * (1-x[1]))
parameter: [rocker, flip]
thickness: {parameter: thickness}
kite4:
kite5:
classname: Kite
kwargs: {}
parameters:
......@@ -139,7 +177,13 @@ subcomponents:
function: 90+(x[0] * (1-x[1]))
parameter: [rocker, flip]
thickness: {parameter: thickness}
kite5:
kite6:
classname: Kite
kwargs: {}
parameters:
angle: 0
thickness: {parameter: thickness}
kite7:
classname: Kite
kwargs: {}
parameters:
......