本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习,本节教程将会介绍如何围绕某个点旋转折线中的顶点。
VectorDraw Developer Framework试用版下载
问:
如何(通过代码)可以围绕某个点旋转折线中的某些顶点,保持其他顶点相同nbsp;
答:
这个问题非常简单,您可以尝试以下代码:
private void MyButton_Click(object sender, EventArgs e) { vdDocument doc = vdFramedControl1.BaseControl.ActiveDocument; doc.New(); Vertexes vrts = new Vertexes(); vrts.Add(1,1,0,0);vrts.Add(1,4,0,0);vrts.Add(4,4,0,0);vrts.Add(5,3,0,0); vdPolyline pl = new vdPolyline(doc, vrts); doc.Model.Entities.AddItem(pl); pl.Invalidate(); //--------------- created the polyline --------- // rotate it for 45 degrees anti-clockwise around vertex[1] Vertexes orig_vert = new Vertexes(pl.VertexList);//get the vertex list of the polyline that will be changed gPoint pt1 = new gPoint(orig_vert[1] as gPoint); // Vertexes from Item 2 and above will change Vertexes keep = new Vertexes(); keep.Add(new Vertex(orig_vert[0])); keep.Add(new Vertex(orig_vert[1])); double orig_angle = pt1.GetAngle( orig_vert[2] as gPoint); // new angle orig_angle += VectorDraw.Geometry.Globals.DegreesToRadians(45.0d); Matrix mat = new Matrix(); mat.TranslateMatrix(-1.0d * pt1); mat.RotateZMatrix(orig_angle); mat.TranslateMatrix(pt1); mat.Transform(orig_vert); // this will produce the new vertexes for (int i = 0; i < 2; i++) { orig_vert[i] = keep[i]; // restore the vertexes that didn't changed } pl.VertexList = orig_vert; pl.Update(); pl.Invalidate(); }
相关资料推荐:
VectorDraw Developer Framework(VDF)示例
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!