internal static IGTMatrix RotateZTransform(double theta, char RorD) { if (RorD == 'D') { theta = (theta * Math.PI) / 180; } double cos = Math.Cos(theta); double sin = Math.Sin(theta); IGTMatrix m = null; try { m = GTClassFactory.Create <IGTMatrix>(); m.M_Matrix[0, 0] = cos; m.M_Matrix[0, 1] = sin; m.M_Matrix[0, 2] = 0.0; m.M_Matrix[0, 3] = 0.0; m.M_Matrix[1, 0] = -sin; m.M_Matrix[1, 1] = cos; m.M_Matrix[1, 2] = 0.0; m.M_Matrix[1, 3] = 0.0; m.M_Matrix[2, 0] = 0.0; m.M_Matrix[2, 1] = 0.0; m.M_Matrix[2, 2] = 1.0; m.M_Matrix[2, 3] = 0.0; m.M_Matrix[3, 0] = 0.0; m.M_Matrix[3, 1] = 0.0; m.M_Matrix[3, 2] = 0.0; m.M_Matrix[3, 3] = 1.0; return(m); } catch (Exception e) { MessageBox.Show(e.Message, "RotateZTransform", MessageBoxButtons.OK); return(null); } }
private IGTMatrix RotateZTransform(double theta, char RorD) { if (RorD == 'D') { theta = (theta * Math.PI) / 180; } double cos = Math.Cos(theta); double sin = Math.Sin(theta); IGTMatrix m = null; try { m = GTClassFactory.Create <IGTMatrix>(); m.M_Matrix[0, 0] = cos; m.M_Matrix[0, 1] = sin; m.M_Matrix[0, 2] = 0.0; m.M_Matrix[0, 3] = 0.0; m.M_Matrix[1, 0] = -sin; m.M_Matrix[1, 1] = cos; m.M_Matrix[1, 2] = 0.0; m.M_Matrix[1, 3] = 0.0; m.M_Matrix[2, 0] = 0.0; m.M_Matrix[2, 1] = 0.0; m.M_Matrix[2, 2] = 1.0; m.M_Matrix[2, 3] = 0.0; m.M_Matrix[3, 0] = 0.0; m.M_Matrix[3, 1] = 0.0; m.M_Matrix[3, 2] = 0.0; m.M_Matrix[3, 3] = 1.0; return(m); } catch (Exception e) { throw; } }
/// <summary> /// Rotates input geometry relative to the reference geom /// </summary> /// <param name="ogeom"></param> /// <returns></returns> private void RotateGeom(IGTGeometry refGeom, ref IGTPolygonGeometry inpGeom) { double dAngle = 0; IGTPolygonGeometry oPolyGeom = null; IGTMatrix tmpTMatrix = null; IGTVector transVec; try { if (refGeom == null || inpGeom == null) { return; } if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTOrientedPointGeometry") { dAngle = AngleBetweenTwoPoints(((IGTOrientedPointGeometry)refGeom).Orientation); } else if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { oPolyGeom = (IGTPolygonGeometry)refGeom.Stroke(); dAngle = AngleBetweenTwoPoints(oPolyGeom.Points[0], oPolyGeom.Points[1]); } transVec = GTClassFactory.Create <IGTVector>(); if (inpGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { oPolyGeom = (IGTPolygonGeometry)inpGeom.Stroke(); // move and rotate the geometry to the correct position transVec.I = oPolyGeom.Points[0].X * -1; transVec.J = oPolyGeom.Points[0].Y * -1; transVec.K = oPolyGeom.Points[0].Z * -1; } tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); // rotate the geometry to the angle of the tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = RotateZTransform(dAngle, 'D'); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); transVec = transVec.NegateVector(transVec); tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } }
private IGTMatrix TranslationTransform(IGTVector Voffset) { IGTMatrix m = null; try { m = GTClassFactory.Create <IGTMatrix>(); m.M_Matrix[0, 0] = 1.0; m.M_Matrix[0, 1] = 0.0; m.M_Matrix[0, 2] = 0.0; m.M_Matrix[0, 3] = 0.0; m.M_Matrix[1, 0] = 0.0; m.M_Matrix[1, 1] = 1.0; m.M_Matrix[1, 2] = 0.0; m.M_Matrix[1, 3] = 0.0; m.M_Matrix[2, 0] = 0.0; m.M_Matrix[2, 1] = 0.0; m.M_Matrix[2, 2] = 1.0; m.M_Matrix[2, 3] = 0.0; m.M_Matrix[3, 0] = Voffset.I; m.M_Matrix[3, 1] = Voffset.J; m.M_Matrix[3, 2] = Voffset.K; m.M_Matrix[3, 3] = 1.0; return(m); } catch (Exception) { throw; } }
internal IGTMatrix TranslationTransform(IGTVector Voffset) { IGTMatrix m = null; try { m = GTClassFactory.Create <IGTMatrix>(); m.M_Matrix[0, 0] = 1.0; m.M_Matrix[0, 1] = 0.0; m.M_Matrix[0, 2] = 0.0; m.M_Matrix[0, 3] = 0.0; m.M_Matrix[1, 0] = 0.0; m.M_Matrix[1, 1] = 1.0; m.M_Matrix[1, 2] = 0.0; m.M_Matrix[1, 3] = 0.0; m.M_Matrix[2, 0] = 0.0; m.M_Matrix[2, 1] = 0.0; m.M_Matrix[2, 2] = 1.0; m.M_Matrix[2, 3] = 0.0; m.M_Matrix[3, 0] = Voffset.I; m.M_Matrix[3, 1] = Voffset.J; m.M_Matrix[3, 2] = Voffset.K; m.M_Matrix[3, 3] = 1.0; return(m); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
/// <summary> /// Rotates input geometry relative to the reference geom /// </summary> /// <param name="ogeom"></param> /// <returns></returns> private void RotateGeom(IGTGeometry refGeom, ref IGTPolygonGeometry inpGeom) { double dAngle = 0; IGTPolygonGeometry oPolyGeom = null; try { if (refGeom == null || inpGeom == null) { return; } if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTOrientedPointGeometry") { dAngle = AngleBetweenTwoPoints(((IGTOrientedPointGeometry)refGeom).Orientation); } else if (refGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { oPolyGeom = (IGTPolygonGeometry)refGeom.Stroke(); dAngle = AngleBetweenTwoPoints(oPolyGeom.Points[0], oPolyGeom.Points[1]); } if (dAngle < -90.0 || dAngle > 90.0) { dAngle = dAngle + 180.0; } IGTVector transVec = GTClassFactory.Create <IGTVector>(); if (inpGeom.GetType().ToString() == "Intergraph.GTechnology.Private.GTPolygonGeometry") { // move and rotate the geometry to the correct position if (m_ActiveMapWindow.DetailID == 0) { transVec.I = refGeom.FirstPoint.X * -1; transVec.J = refGeom.FirstPoint.Y * -1; transVec.K = refGeom.FirstPoint.Z * -1; } else { if (m_CentriodPoint != null) { transVec.I = m_CentriodPoint.X * -1; transVec.J = m_CentriodPoint.Y * -1; transVec.K = m_CentriodPoint.Z * -1; } } } IGTMatrix tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); // rotate the geometry to the angle of the tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = RotateZTransform(dAngle, 'D'); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); transVec = transVec.NegateVector(transVec); tmpTMatrix = GTClassFactory.Create <IGTMatrix>(); tmpTMatrix = TranslationTransform(transVec); inpGeom = (IGTPolygonGeometry)inpGeom.Multiply(inpGeom, tmpTMatrix); } catch (Exception) { throw; } finally { } }