private POINT3D ScalePoint(POINT3D p, float aX, float aY, float aZ) { // Thực hiện phép Scale biến điểm p thành điểm kết quả POINT3D result = new POINT3D(); result.x = p.x * aX; result.y = p.y * aY; result.z = p.z * aZ; return(result); }
private POINT3D TranslationPoint(POINT3D p, POINT3D oldCoord, POINT3D newCoord) { // Thực hiện tịnh tiến biến điểm p thành điểm kết quả POINT3D result = new POINT3D(); result.x = p.x + newCoord.x - oldCoord.x; result.y = p.y + newCoord.y - oldCoord.y; result.z = p.z + newCoord.z - oldCoord.z; return(result); }
private POINT3D RotatePoint(POINT3D p, float alphaX, float alphaY, float alphaZ) { // Thực hiện phép xoay biến điểm p thành điểm kết quả. POINT3D result = new POINT3D(); result = RotatePoint_xCoord(p, alphaX); // xoay theo trục x result = RotatePoint_yCoord(result, alphaY); //xoay theo trục y result = RotatePoint_zCoord(result, alphaZ); // xoay theo trục z return(result); }
private void Transform_Button_Click(object sender, EventArgs e) { // Button biến đổi hình Form2 f2 = new Form2(); f2.ShowDialog(); //Tịnh tiến POINT3D newCoord = new POINT3D(); newCoord.x = f2.positionX; newCoord.y = f2.positionY; newCoord.z = f2.positionZ; //Xoay quanh trục float alphaX, alphaY, alphaZ; alphaX = f2.rotateX; alphaY = f2.rotateY; alphaZ = f2.rotateZ; //Zoom ảnh float scaleX, scaleY, scaleZ; scaleX = f2.scaleX; scaleY = f2.scaleY; scaleZ = f2.scaleZ; switch (kind3D) { case "Cube": TranslationWireframe(ref Cube, new POINT3D(0, 0, 0), newCoord); RotateWireframe(ref Cube, alphaX, alphaY, alphaZ); ScaleWireframe(ref Cube, scaleX, scaleY, scaleZ); break; case "Pyramid": TranslationWireframe(ref Pyramid, new POINT3D(0, 0, 0), newCoord); RotateWireframe(ref Pyramid, alphaX, alphaY, alphaZ); ScaleWireframe(ref Pyramid, scaleX, scaleY, scaleZ); break; case "Prism": TranslationWireframe(ref Prism, new POINT3D(0, 0, 0), newCoord); RotateWireframe(ref Prism, alphaX, alphaY, alphaZ); ScaleWireframe(ref Prism, scaleX, scaleY, scaleZ); break; } }
private POINT3D RotatePoint_zCoord(POINT3D p, float alphaZ) { // Hàm xoay theo trục z // Ma trận xoay theo trục z // [[cos(alpha), -sin(alpha), 0, 0], // [sin(alpha), cos(alpha), 0, 0], // [0, 0, 1, 0], // [0, 0, 0, 1]] POINT3D result = new POINT3D(); result.x = Convert.ToSingle(p.x * Math.Cos(alphaZ) - p.y * Math.Sin(alphaZ)); result.y = Convert.ToSingle(p.x * Math.Sin(alphaZ) + p.y * Math.Cos(alphaZ)); result.z = p.z; return(result); }
private POINT3D RotatePoint_yCoord(POINT3D p, float alphaY) { // Hàm xoay theo trục y // Ma trận xoay theo trục y // [[cos(alpha), 0, sin(alpha), 0], // [0, 1, 0, 0], // [-sin(alpha), 0, cos(alpha), 0], // [0, 0, 0, 1]] POINT3D result = new POINT3D(); result.x = Convert.ToSingle(p.x * Math.Cos(alphaY) + p.z * Math.Sin(alphaY)); result.y = p.y; result.z = Convert.ToSingle(-p.x * Math.Sin(alphaY) + p.z * Math.Cos(alphaY)); return(result); }
private POINT3D RotatePoint_xCoord(POINT3D p, float alphaX) { // Hàm xoay theo trục x // Ma trận xoay theo trục x // [[1, 0, 0, 0], // [0, cos(alpha), -sin(alpha), 0], // [0, sin(alpha), cos(alpha), 0], // [0, 0, 0, 1]] POINT3D result = new POINT3D(); result.x = p.x; result.y = Convert.ToSingle(p.y * Math.Cos(alphaX) - p.z * Math.Sin(alphaX)); result.z = Convert.ToSingle(p.y * Math.Sin(alphaX) + p.z * Math.Cos(alphaX)); return(result); }
private void TranslationWireframe(ref WIREFRAME wf, POINT3D oldCoord, POINT3D newCoord) { // Thực hiện phép tịnh tiến cho khối 3D // Biến đổi tất cả các đỉnh for (int i = 0; i < wf.Vert.Count(); i++) { wf.Vert[i] = TranslationPoint(wf.Vert[i], oldCoord, newCoord); } // Biến đổi tất cả các cạnh for (int j = 0; j < wf.Edge.Count(); j++) { wf.Edge[j].p_start = TranslationPoint(wf.Edge[j].p_start, oldCoord, newCoord); wf.Edge[j].p_end = TranslationPoint(wf.Edge[j].p_end, oldCoord, newCoord); } // Biến đổi tất cả các đa giác for (int k = 0; k < wf.Polygon.Count(); k++) { for (int l = 0; l < wf.Polygon[k].aVertex.Count(); l++) { wf.Polygon[k].aVertex[l] = TranslationPoint(wf.Polygon[k].aVertex[l], oldCoord, newCoord); } } }
public static int GetLineEndPoint3d(COMMAND_ENTITY commandSlave, string blockName, string nameEntity, out POINT3D value) { int iRes = 0; value = new POINT3D(); EntityParser.ProxyEntity entityFind; // ??? проверить на корректность связи ведущий-ведомый (есть ли сопряжение по оси) INDEX_COORD3d indxCoord3dLeading = INDEX_COORD3d.UNKNOWN , indxCoord3dSlave = INDEX_COORD3d.UNKNOWN; switch (commandSlave) { //case COMMAND_ENTITY.ALINE_X: case COMMAND_ENTITY.RLINE_X: indxCoord3dSlave = INDEX_COORD3d.X; break; //case COMMAND_ENTITY.ALINE_Y: case COMMAND_ENTITY.RLINE_Y: indxCoord3dSlave = INDEX_COORD3d.Z; break; //case COMMAND_ENTITY.ALINE_Z: case COMMAND_ENTITY.RLINE_Z: indxCoord3dSlave = INDEX_COORD3d.Z; break; default: break; } if (s_dictBlock.ContainsKey(blockName) == true) { entityFind = s_dictBlock[blockName].m_dictEntityParser.Values.First(entity => { return(entity.m_name.Equals(nameEntity) == true); }); if (!(entityFind.m_command == COMMAND_ENTITY.UNKNOWN)) { switch (entityFind.m_command) { case COMMAND_ENTITY.LINE: indxCoord3dLeading = INDEX_COORD3d.ANY; break; case COMMAND_ENTITY.ALINE_X: //case COMMAND_ENTITY.RLINE_X: indxCoord3dLeading = INDEX_COORD3d.X; break; case COMMAND_ENTITY.ALINE_Y: //case COMMAND_ENTITY.RLINE_Y: indxCoord3dLeading = INDEX_COORD3d.Z; break; case COMMAND_ENTITY.ALINE_Z: //case COMMAND_ENTITY.RLINE_Z: indxCoord3dLeading = INDEX_COORD3d.Z; break; default: break; } iRes = ((indxCoord3dLeading == indxCoord3dSlave) || (indxCoord3dLeading == INDEX_COORD3d.ANY)) ? 0 : -1; if (iRes == 0) { value = new POINT3D(new double[] { (double)entityFind.GetProperty(MSExcel.HEAP_INDEX_COLUMN.LINE_END_DECART_X) , (double)entityFind.GetProperty(MSExcel.HEAP_INDEX_COLUMN.LINE_END_DECART_Y) , (double)entityFind.GetProperty(MSExcel.HEAP_INDEX_COLUMN.LINE_END_DECART_Z) }); } } else { iRes = -2; } } else { iRes = -3; } return(iRes); }
public EDGE(POINT3D start, POINT3D end) { this.p_start = start; this.p_end = end; }
public EDGE() { p_start = new POINT3D(); p_end = new POINT3D(); }