Bounds TwoBounds(Bounds source, int min, int max) { var shift = shiftDir.Eval(); var one = source; one.center += shift * min; var two = source; two.center += shift * max; one.Encapsulate(two); return(one); }
public ExpVector PointOn(Exp a, ExpVector point) { /* * var ax = GetAxis(); * var axn = ax.Normalized(); * var o = GetOrigin(); * var prj = ExpVector.ProjectPointToLine(point, o, o + ax); * var ra = Exp.Atan2(new Exp(step) / 4.0, (point - prj).Magnitude()); */ var ax = GetAxis().Eval(); var axn = ax.normalized; var o = GetOrigin().Eval(); var prj = ExpVector.ProjectPointToLine(point.Eval(), o, o + ax); var t = a / (2.0 * Mathf.PI); var ra = Exp.Atan2(new Exp(step) / 4.0, (point.Eval() - prj).magnitude); var res = ExpVector.RotateAround(point, point - prj, o, ra); res = ExpVector.RotateAround(res, ax, o, a); return(res + (ExpVector)axn * t * step); }
/* * protected override void OnDraw(LineCanvas canvas) { * var l0 = GetEntityOfType(IEntityType.Line, 0); * var l1 = GetEntityOfType(IEntityType.Line, 1); * DrawStroke(canvas, l0, 0); * DrawStroke(canvas, l1, 1); * if(DetailEditor.instance.hovered == this) { * DrawReferenceLink(canvas, Camera.main); * } * } */ protected override void OnDraw(LineCanvas canvas) { var line0 = GetEntityOfType(IEntityType.Line, 0); var line1 = GetEntityOfType(IEntityType.Line, 1); ExpVector p0 = null; ExpVector p1 = null; ExpVector p2 = null; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { if (line0.GetPointAtInPlane(i, null).ValuesEquals(line1.GetPointAtInPlane(j, null), 1e-6)) { p0 = line0.GetPointAtInPlane(i, null); p1 = line0.GetPointAtInPlane((i + 1) % 2, null); p2 = line1.GetPointAtInPlane((j + 1) % 2, null); } } } float pix = getPixelSize(); if (p0 != null) { Vector3 p = p0.Eval(); Vector3 dir1 = p1.Eval() - p; Vector3 dir2 = p2.Eval() - p; dir1 = dir1.normalized * pix * 13f; dir2 = dir2.normalized * pix * 13f; Vector3 corner = p + dir1 + dir2; canvas.DrawLine(p + dir1, corner); canvas.DrawLine(p + dir2, corner); ref_points[0] = ref_points[1] = sketch.plane.ToPlane(corner); } else { for (int i = 0; i < 2; i++) { var line = GetEntityOfType(IEntityType.Line, i); Vector3 a = line.GetPointAtInPlane(0, null).Eval(); Vector3 b = line.GetPointAtInPlane(1, null).Eval(); Vector3 dir = normalize(a - b); Vector3 center = a + (b - a) * 0.5f; Vector3 plane = getVisualPlaneDir(Camera.main.transform.forward); Vector3 perp = normalize(Vector3.Cross(dir, plane)); Vector3 p = center - perp * pix * 8.0f; canvas.DrawLine(p - dir * pix * 8.0f, p + dir * pix * 8.0f); canvas.DrawLine(p, p - perp * pix * 13.0f); ref_points[i] = sketch.plane.ToPlane(p - perp * pix * 6.0f); } if (DetailEditor.instance.hovered == this) { DrawReferenceLink(canvas, Camera.main); } } }