PixelFarm.Drawing.PointD CreateExtendedInnerEdges(PixelFarm.Drawing.PointD p0, PixelFarm.Drawing.PointD p1) { PixelFarm.VectorMath.Vector2 v2 = new PixelFarm.VectorMath.Vector2(p1.X - p0.X, p1.Y - p0.Y); PixelFarm.VectorMath.Vector2 r1 = v2.RotateInDegree(270).NewLength(3); return(new PixelFarm.Drawing.PointD(p1.X + r1.x, p1.Y + r1.Y)); //if (LeftPointKind == Vec2PointKind.Touch1 || LeftPointKind == Vec2PointKind.Touch2) //{ // double rad = Math.Atan2(p1.Y - p0.Y, p1.X - p0.X); // double currentLen = CurrentLen(p0, p1); // if (currentLen - 3 < 0) // { // return p0;//*** // } // double newLen = currentLen - 3; // //double new_dx = Math.Cos(rad) * newLen; // //double new_dy = Math.Sin(rad) * newLen; // return new PixelFarm.Drawing.PointD(p0.X + (Math.Cos(rad) * newLen), p0.Y + (Math.Sin(rad) * newLen)); //} //else //{ // PixelFarm.VectorMath.Vector2 v2 = new PixelFarm.VectorMath.Vector2(p1.X - p0.X, p1.Y - p0.Y); // PixelFarm.VectorMath.Vector2 r1 = v2.RotateInDegree(270).NewLength(3); // return new PixelFarm.Drawing.PointD(p1.X + r1.x, p1.Y + r1.Y); //} }
PixelFarm.Drawing.PointD CreateExtendedOuterEdges(PixelFarm.Drawing.PointD p0, PixelFarm.Drawing.PointD p1, double dlen = 3) { //create perpendicular line PixelFarm.VectorMath.Vector2 v2 = new PixelFarm.VectorMath.Vector2(p1.X - p0.X, p1.Y - p0.Y); PixelFarm.VectorMath.Vector2 r1 = v2.RotateInDegree(90).NewLength(3); return(new PixelFarm.Drawing.PointD(p1.X + r1.x, p1.Y + r1.Y)); //if (LeftPointKind == Vec2PointKind.Touch1 || LeftPointKind == Vec2PointKind.Touch2) //{ // double rad = Math.Atan2(p1.Y - p0.Y, p1.X - p0.X); // double currentLen = CurrentLen(p0, p1); // double newLen = currentLen + dlen; // //double new_dx = Math.Cos(rad) * newLen; // //double new_dy = Math.Sin(rad) * newLen; // return new PixelFarm.Drawing.PointD(p0.X + (Math.Cos(rad) * newLen), p0.Y + (Math.Sin(rad) * newLen)); //} //else //{ // //create perpendicular line // PixelFarm.VectorMath.Vector2 v2 = new PixelFarm.VectorMath.Vector2(p1.X - p0.X, p1.Y - p0.Y); // PixelFarm.VectorMath.Vector2 r1 = v2.RotateInDegree(90).NewLength(3); // return new PixelFarm.Drawing.PointD(p1.X + r1.x, p1.Y + r1.Y); //} }
static void CreateInnerBorder(VertexStore vxs, double x0, double y0, double x1, double y1, double w) { //create 'inner border box' of a line a line (x0,y0)=>(x1,y1) PixelFarm.VectorMath.Vector2 vector = new PixelFarm.VectorMath.Vector2(x1 - x0, y1 - y0); //for inner border, we don't extend both endpoint //rotate 270 degree to create a height vector that point 'inside' of the 'rectbox' shape. //the box height= w PixelFarm.VectorMath.Vector2 vdiff = vector.RotateInDegree(270).NewLength(w); vxs.AddMoveTo(x0, y0); vxs.AddLineTo(x1, y1); vxs.AddLineTo(x1 + vdiff.x, y1 + vdiff.y); vxs.AddLineTo(x0 + vdiff.x, y0 + vdiff.y); vxs.AddCloseFigure(); }
static void CreateOuterBorder(VertexStore vxs, double x0, double y0, double x1, double y1, double w) { //create 'outer border box' of a line (x0,y0)=>(x1,y1) PixelFarm.VectorMath.Vector2 vector = new PixelFarm.VectorMath.Vector2(x1 - x0, y1 - y0); //for outer border, we need to extend both endpoints with len w //this will create overlapped area outside the shape. PixelFarm.VectorMath.Vector2 ext_vec = vector.NewLength(w); x0 -= ext_vec.x; y0 -= ext_vec.y; x1 += ext_vec.x; y1 += ext_vec.y; //rotate 90 degree to create a height vector that point to 'outside' of the 'rectbox' shape. //the box height= w PixelFarm.VectorMath.Vector2 h_vec = vector.RotateInDegree(90).NewLength(w); vxs.AddMoveTo(x0, y0); vxs.AddLineTo(x0 + h_vec.x, y0 + h_vec.y); vxs.AddLineTo(x1 + h_vec.x, y1 + h_vec.y); vxs.AddLineTo(x1, y1); vxs.AddCloseFigure(); }
void IVector2dProvider.GetCoord(int index, out float x, out float y) { PixelFarm.VectorMath.Vector2 vec = _vecSource[index]; x = (float)vec.x; y = (float)vec.y; }
void IVector2dProvider.GetCoord(int index, out double x, out double y) { PixelFarm.VectorMath.Vector2 vec = _vecSource[index]; x = vec.x; y = vec.y; }