struct Turtle (
position_ = [0, 0, 0],
heading_= [0, 1, 0],
rotationQuat_ = quat 0 0 0 1,
amount = 200,
turnAngle = 45,
fn forward = (
c = box pos: position_ wirecolor: red width: 40 length: amount height: 2 lengthSegs: 10
rotate c rotationQuat_
position_ = position_ + amount * heading_
),
fn left = (
q = quat -turnAngle [0, 0, 1]
rotationQuat_ = q * rotationQuat_
invq = inverse q
heading_ = heading_ * invq
c = box pos: position_ wirecolor: red width: 40 length: amount height: 2 lengthSegs: 10
addmodifier c (bend())
c.bend.bendAngle = 45
c.bend.bendAxis = 1
rotate c rotationQuat_
position_ = position_ + amount * heading_
),
fn right = (
q = quat turnAngle [0, 0, 1]
rotationQuat_ = q * rotationQuat_
invq = inverse q
heading_ = heading_ * invq
c = box pos: position_ wirecolor: red width: 40 length: amount height: 2 lengthSegs: 10
addmodifier c (bend())
c.bend.bendangle = -45
c.bend.bendAxis = 1
rotate c rotationQuat_
position_ = position_ + amount * heading_
)
)
fn main = (
delete objects
t = Turtle()
t.left()
t.left()
t.left()
t.left()
t.left()
t.left()
t.left()
t.right()
t.forward()
t.forward()
t.right()
)
main()
我正在尝试使用海龟图形创建一条路径,但因为一旦你弯曲盒子就不能正确排列我无法让它们对齐。我设法通过更改每个形状的枢轴点使其暂时工作,但它是硬编码的,因此只能在某些情况下工作。我怎样才能让每个盒子对齐?