本文整理汇总了C#中Stroke.GetPoint方法的典型用法代码示例。如果您正苦于以下问题:C# Stroke.GetPoint方法的具体用法?C# Stroke.GetPoint怎么用?C# Stroke.GetPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stroke
的用法示例。
在下文中一共展示了Stroke.GetPoint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryTapToSelect
private void TryTapToSelect(Stroke stroke)
{
// We interpret strokes with fewer than 25 packets,
// starting and ending on the same body, as tap gestures.
int np = stroke.PacketCount;
Point head = stroke.GetPoint(0), tail = stroke.GetPoint(np-1);
RigidBodyBase[] headhits = doc.HitTestBodies(head);
RigidBodyBase[] tailhits = doc.HitTestBodies(tail);
if (np <= 25 &&
headhits.Length > 0 &&
tailhits.Length > 0 &&
Object.ReferenceEquals(headhits[0],tailhits[0]))
{
tappedbody = headhits[0];
// Ensure we didn't just tap what's already selected.
ArrayList selbodies = new ArrayList(
doc.GetBodiesFor(inkoverlay.Selection));
if (selbodies.Contains(tappedbody))
return;
// We must delay the call to set_Selection, until after InkOverlay is
// finished looking at this stroke. BeginInvoke seems to work nicely
// for this purpose.
dbg.WriteLine("-------TTS--------");
base.BeginInvoke(new MethodInvoker(DelayTapToSelect));
}
}
示例2: MakeRodRopeOrSpring
private MechanismBase MakeRodRopeOrSpring(Stroke stroke, RigidBodyBase headbody, RigidBodyBase tailbody)
{
// Rod, Rope, or Spring: we decide based on straightness, curvyness, and loopiness.
int np = stroke.PacketCount;
Point head = stroke.GetPoint(0), tail = stroke.GetPoint(np-1);
double distance = Geometry.DistanceBetween(head,tail);
StrokeGeometry sg = new StrokeGeometry(stroke);
double length = sg.IntegrateLength();
// Consider spring: analyze total net curvature of the stroke, and call it a
// spring if it makes at least 540 degrees (1.5 loops) in the same direction.
double tt = StrokeAnalyzer.AnalyzeTotalCurvature(stroke,100.0);
if (Math.Abs(Geometry.Rad2Deg(tt)) > 540.0)
{
dbg.WriteLine("new SpringMech");
SpringMech newmech = new SpringMech();
newmech.EndpointA = BodyRef.For(headbody,head);
newmech.EndpointB = BodyRef.For(tailbody,tail);
newmech.extension = distance;
newmech.stiffness = MathEx.Square(tt)/100; //Heuristic: th²/100 feels about right.
newmech.strokeid = stroke.Id;
doc.Mechanisms.Add(newmech);
return newmech;
}
// Straight and narrow?
double rodropethreshold = 1.1; //heuristic
if (length/distance < rodropethreshold)
{
dbg.WriteLine("new RodMech");
RodMech newmech = new RodMech();
newmech.EndpointA = BodyRef.For(headbody,head);
newmech.EndpointB = BodyRef.For(tailbody,tail);
newmech.length = distance;
newmech.strokeid = stroke.Id;
doc.Mechanisms.Add(newmech);
return newmech;
}
else
{
dbg.WriteLine("new RopeMech");
RopeMech newmech = new RopeMech();
newmech.EndpointA = BodyRef.For(headbody,head);
newmech.EndpointB = BodyRef.For(tailbody,tail);
newmech.length = length;
newmech.strokeid = stroke.Id;
doc.Mechanisms.Add(newmech);
return newmech;
}
}
示例3: TappedNode
/* Determines whether the given stroke was a tap
* on a node in Graph g and if so, returns that node
*/
public static Node TappedNode(Stroke s, Graph g)
{
if(s.PacketCount > 25) return null;
Point[] points = {s.GetPoint(0),s.GetPoint(s.PacketCount-1)};
foreach(Node n in g.Nodes)
{
Rectangle r = n.Stroke.GetBoundingBox();
if(r.Contains(points[0]) && r.Contains(points[1]))
return n;
}
return null;
}
示例4: AnalyzeClosedness
// out double tAB, out double tPQ)
public static void AnalyzeClosedness(Stroke stroke, double tolerance,
out bool closed, out Point[] vertices)
{
closed = false;
vertices = null;
// Formulate closure gap-tolerance, based on stroke length (but clipped to <= 500isu).
double len = StrokeGeometry.IntegrateLength(stroke);
double segtol = Math.Max(50,Math.Min(tolerance,len/20.0));
double gaptol = Math.Max(150,Math.Min(tolerance,len/7.0));
dbg.WriteLine(String.Format("length: {0}",len));
dbg.WriteLine(String.Format("segtol: {0}",segtol));
dbg.WriteLine(String.Format("gaptol: {0}",gaptol));
// Break the stroke down into indices.
int[] indices;
vertices = SegmentizeStroke(stroke,segtol, out indices);
int nv = vertices.Length;
// Do the head/tail segments intersect? Are they close?
if (nv >= 4)
{
Point headA = (Point)vertices[0];
Point headB = (Point)vertices[1];
Point tailP = (Point)vertices[nv-2];
Point tailQ = (Point)vertices[nv-1];
double tAB, tPQ;
SegmentCollision.HitTest(headA,headB,tailP,tailQ, out tAB, out tPQ);
Point virtualIntersectH = Geometry.Interpolate(headA,headB,tAB);
Point virtualIntersectT = Geometry.Interpolate(tailP,tailQ,tPQ);
Point virtualIntersect = Geometry.Interpolate(virtualIntersectH,virtualIntersectT,0.5);
double dh2i = Geometry.DistanceBetween(headA,virtualIntersect);
double dt2i = Geometry.DistanceBetween(tailQ,virtualIntersect);
#if DEBUG
dbg.WriteLine(String.Format("numV: {0}",nv));
dbg.WriteLine(String.Format("tAB: {0}",tAB));
dbg.WriteLine(String.Format("tPQ: {0}",tPQ));
dbg.WriteLine(String.Format("isct: {0}",virtualIntersect));
dbg.WriteLine(String.Format("dh2i: {0}",dh2i));
dbg.WriteLine(String.Format("dt2i: {0}",dt2i));
#endif
if (dh2i < gaptol && dt2i < gaptol)
{
closed = true;
// Adjust the head point to the actual intersection.
vertices[0] = virtualIntersect;
dbg.WriteLine("Closed! Why? dh/t2i < gaptol");
}
else if ((-0.3 < tAB && tAB < 0.3) && (0.7 < tPQ && tPQ < 1.3))
{
closed = true;
// Adjust the head point to the actual intersection.
vertices[0] = virtualIntersect;
dbg.WriteLine("Closed! Why? |t*| < 0.3");
}
else
{
// Last chance: measure nearest distance from head to tail segment.
int closeI = StrokeGeometry.FindClosestPointTo(
stroke, headA, indices[nv-2], indices[nv-1]);
Point close = stroke.GetPoint(closeI);
double d = Geometry.DistanceBetween(headA,close);
if (d < gaptol)
{
closed = true; // Keep the head point; discard the tail point below.
dbg.WriteLine("Closed! Why? Last chance head/tail distance < gaptol");
}
}
// Remove the last point as redundant if it's closed.
if (closed)
{
Point[] verticesX = new Point[nv-1];
Array.Copy(vertices,verticesX,nv-1);
vertices = verticesX;
}
}
}
示例5: isClosed
/* Returns true if the stroke is somewhat closed in the
* sense that it comes back to itself. Accomplishes
* this by checking the distance between the first point
* in the stroke and the last point in the stroke.
*/
public static bool isClosed(Stroke s, double tolerance)
{
if(s == null)
return false;
Point[] pts = {s.GetPoint(0), s.GetPoint(s.PacketCount-1)};
return StrokeManager.Distance(pts[0], pts[1]) <= tolerance;
}