Exemplo n.º 1
0
 def update(self, point):
     "sets the opposite (diagonal) point of the rectangle"
     diagonal = point.sub(self.origin)
     inpoint1 = self.origin.add(fcvec.project(diagonal, self.v))
     inpoint2 = self.origin.add(fcvec.project(diagonal, self.u))
     self.coords.point.set1Value(1, inpoint1.x, inpoint1.y, inpoint1.z)
     self.coords.point.set1Value(2, point.x, point.y, point.z)
     self.coords.point.set1Value(3, inpoint2.x, inpoint2.y, inpoint2.z)
Exemplo n.º 2
0
 def getClosestNode(self, point):
     "returns the closest node from the given point"
     # get the 2D coords.
     point = plane.projectPoint(point)
     u = fcvec.project(point, plane.u)
     lu = u.Length
     if u.getAngle(plane.u) > 1.5:
         lu = -lu
     v = fcvec.project(point, plane.v)
     lv = v.Length
     if v.getAngle(plane.v) > 1.5:
         lv = -lv
     # print "u = ",u," v = ",v
     # find nearest grid node
     pu = (round(lu / self.space, 0)) * self.space
     pv = (round(lv / self.space, 0)) * self.space
     rot = FreeCAD.Rotation()
     rot.Q = self.trans.rotation.getValue().getValue()
     return rot.multVec(Vector(pu, pv, 0))
Exemplo n.º 3
0
 def getSize(self):
     "returns (length,width) of the rectangle"
     p1 = Vector(self.coords.point.getValues()[0].getValue())
     p2 = Vector(self.coords.point.getValues()[2].getValue())
     diag = p2.sub(p1)
     return ((fcvec.project(diag, self.u)).Length, (fcvec.project(diag, self.v)).Length)