public override bool HitTest(HitLine hit) { if (Anchor2 == null) return false; for (int i = 0; i < solidPoints.Length - 1; i++) { HitLine line = new HitLine() { Front = solidPoints[i], Back = solidPoints[i + 1], Camera = hit.Camera }; if (line.ShortestDistance(hit) < HitTol * hit.Camera.SceneToWorldScaling) { lastHit = hit.GetIntersection((ParentEntity as Sketch).Plane); return true; } } return false; }
public override bool HitTest(HitLine hit) { if (Points.Count == 0) return false; for (int i = 0; i < Points.Count - 1; i++) { HitLine line = new HitLine() { Front = Points[i].ToVector(), Back = Points[i+1].ToVector(), Camera = hit.Camera }; if (line.ShortestDistance(hit) < HitTol * hit.Camera.SceneToWorldScaling) { lastHit = hit.GetIntersection((ParentEntity as Sketch).Plane); return true; } } return false; }
public override bool HitTest(HitLine hit) { if (Center == null) return false; // set the last hit, even if we didn't hit anything lastHit = hit.GetIntersection((ParentEntity as Sketch).Plane); // test for hitting the center Coord center = hit.Camera.WorldToScreen(Center.ToVector()); double distance = (hit.Screen - center).Magnitude; if (distance < Arc.HitTol) return true; if (Start == null) return false; // test for hitting the circle Coord start = hit.Camera.WorldToScreen(Start.ToVector()); double radius = (start - center).Magnitude; if (Math.Abs(distance - radius) < Arc.HitTol) return true; return false; }
/// <summary> /// Finds the intersection of the hit line and the plane. /// </summary> /// <remarks>The vector will be snapped if ModelingOptions.Global.SnapToGrid.</remarks> public Vector GetIntersection(HitLine hit) { Vector vec = hit.GetIntersection(this); if (ModelingOptions.Global.SnapToGrid) vec = SnapToGrid(vec); return vec; }
/// <summary> /// Gets a point in control-space corresponding to the hit line in 3D space. /// </summary> private Coord GetControlPoint(HitLine hitLine) { if (RenderSize == null) return new Coord(); var intersection = hitLine.GetIntersection(this); var point = this.Project(intersection) / _scaling; point.Y = RenderHeight - point.Y; return point; }
public override bool HitTest(HitLine hit) { if (Anchor2 == null) return false; // get the major and minor axes Vector x = Sketch.Plane.LocalX; Vector y = Sketch.Plane.LocalY; Vector center = Center.ToVector(); double a = x.Dot(Anchor2.ToVector() - center); double b = y.Dot(Anchor2.ToVector() - center); // rotate the coordinate system to the tilt if (Tilt.Value != 0) { x = x.Rotate((ParentEntity as Sketch).Plane.Normal, Tilt); y = y.Rotate((ParentEntity as Sketch).Plane.Normal, Tilt); } // project the hit onto the plane's coordinate system lastHit = hit.GetIntersection((ParentEntity as Sketch).Plane); double hitX = (lastHit - center).Dot(x); double hitY = (lastHit - center).Dot(y); // test for the hit double hitTol = 0.1; if (Math.Abs(1 - hitX * hitX / (a * a) - hitY * hitY / (b * b)) < hitTol) return true; return false; }