internal static IPoint3D ComputeCatmullClarkEdgeVertexPosition(int[] keys, IMesh m) { IVector3D v = new IVector3D(); if (!m.Topology.IsNakedEdge(keys[0], keys[1])) { // Edge ends average for (int i = 0; i < keys.Length; i++) { v += m.GetVertexWithKey(keys[i]).Position; } //Face centers average int[] incidentE = m.Topology.GetEdgeIncidentElements(keys[0], keys[1]); IElement e; foreach (int eKey in incidentE) { e = m.GetElementWithKey(eKey); v += ComputeAveragePosition(e.Vertices, m); } v /= (incidentE.Length + keys.Length); return(new IPoint3D(v.X, v.Y, v.Z)); } else { return(ComputeAveragePosition(keys, m)); } }
public IGeometry CreateGeometry(double radius, IPolyline polyline, double qdgc, double zdgc) { IPointCollection pointCollection = CreatePointCollectionForCircle(radius); IVector3D pVectorZ = new Vector3DClass(); pVectorZ.SetComponents(0, 0, 1); IConstructMultiPatch patch = new MultiPatchClass(); IZAware zAware = pointCollection as IZAware; if (zAware == null) { return(null); } zAware.ZAware = true; // 依据管线长度拉伸 patch.ConstructExtrude(polyline.Length, pointCollection as IGeometry); // 依据管线角度旋转 IVector3D pVector3D = new Vector3DClass(); pVector3D.SetComponents(polyline.ToPoint.X - polyline.FromPoint.X, polyline.ToPoint.Y - polyline.FromPoint.Y, zdgc - qdgc); double rotateAngle = Math.Acos(pVector3D.ZComponent / pVector3D.Magnitude); IVector3D vectorAxis = pVectorZ.CrossProduct(pVector3D) as IVector3D; ITransform3D transform3D = patch as ITransform3D; transform3D.RotateVector3D(vectorAxis, rotateAngle); // 平移到指定位置 transform3D.Move3D(polyline.FromPoint.X, polyline.FromPoint.Y, qdgc); return(patch as IGeometry); }
private IVector GetClosingVector(List <IVector3D> TraverseCourses, IPoint StartPoint, IPoint EndPoint, out double SUMofLengths) { IVector SumVec = null; SUMofLengths = 0; for (int i = 0; i < TraverseCourses.Count - 1; i++) { if (i == 0) { SUMofLengths = TraverseCourses[0].Magnitude + TraverseCourses[1].Magnitude; SumVec = TraverseCourses[0].AddVector(TraverseCourses[1]); } else { IVector3D SumVec3D = SumVec as IVector3D; SUMofLengths += TraverseCourses[i + 1].Magnitude; SumVec = SumVec3D.AddVector(TraverseCourses[i + 1]); } } double dCalcedEndX = StartPoint.X + SumVec.ComponentByIndex[0]; double dCalcedEndY = StartPoint.Y + SumVec.ComponentByIndex[1]; IVector3D CloseVector3D = new Vector3DClass(); CloseVector3D.SetComponents(dCalcedEndX - EndPoint.X, dCalcedEndY - EndPoint.Y, 0); IVector CloseVector = CloseVector3D as IVector; return(CloseVector); }
/// <summary> /// 更新半径 /// </summary> /// <param name="radius"></param> public void UpdatePosition(double radius) { this.radius = radius; IZAware zAware = (IGeometry)centerPoint as IZAware; zAware.ZAware = true; upperAxisVector3D = new Vector3DClass(); upperAxisVector3D.SetComponents(0, 0, 10); lowerAxisVector3D = new Vector3DClass(); lowerAxisVector3D.SetComponents(0, 0, -10); lowerAxisVector3D.XComponent -= vectorComponentOffset; normalVector3D = upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D; normalVector3D.Magnitude = this.radius; double rotationAngleInRadians = 2 * (Math.PI / 180); geometryCollection = new MultiPatchClass(); pointCollection.RemovePoints(0, pointCollection.PointCount); for (int i = 0; i < 180; i++) { normalVector3D.Rotate(-1 * rotationAngleInRadians, upperAxisVector3D); IPoint vertexPoint = new PointClass(); vertexPoint.X = centerPoint.X + normalVector3D.XComponent; vertexPoint.Y = centerPoint.Y + normalVector3D.YComponent; vertexPoint.Z = centerPoint.Z; pointCollection.AddPoint(vertexPoint, missing, missing); } base.Geometry = pointCollection as IGeometry; this.Update(); }
public double Angle(IVector3D vec) { var dot = this * vec; var len = Length() * vec.Length(); return(Math.Acos(dot / len)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IMesh mesh = new IMesh(); List <Vector3d> vec = new List <Vector3d>(); List <int> vKey = new List <int>(); DA.GetData(0, ref mesh); DA.GetDataList(1, vKey); DA.GetDataList(2, vec); IMesh dM = mesh.DeepCopy(); IVector3D T = new IVector3D(vec[0]); bool flag = vKey.Count.Equals(vec.Count); for (int i = 0; i < vKey.Count; i++) { ITopologicVertex v = dM.GetVertexWithKey(vKey[i]); if (flag) { T = new IVector3D(vec[i]); } dM.SetVertexPosition(vKey[i], v.Position + T); } dM.UpdateGraphics(); DA.SetData(0, dM); }
public static IMesh Skew(IMesh mesh, IPlane plane = default, IVector3D skewDirection = default, double skewFactor = 1.0) { IMesh dM = mesh.DeepCopy(); if (plane == default) { plane = IPlane.WorldXY; } if (skewDirection == default) { skewDirection = IVector3D.UnitZ; } IPoint3D pt; double d; foreach (int vK in dM.VerticesKeys) { pt = dM.GetVertexWithKey(vK).Position; d = plane.DistanceToPlane(pt); if (d > 0) { pt += IVector3D.Mult(skewDirection, d * skewFactor); } dM.SetVertexPosition(vK, pt); } dM.UpdateGraphics(); return(dM); }
internal static IPoint3D GetClosestPointToFictiousLine(IPoint3D p, IPoint3D lineStart, IPoint3D lineEnd) { IVector3D direction = lineEnd - lineStart; IVector3D projection = lineStart - p; IPoint3D pos; double t = IVector3D.Dot(projection, direction); if (t <= 0) { return(lineStart); } else { double eval = Math.Pow(lineStart.DistanceTo(lineEnd), 2); if (t >= eval) { return(lineEnd); } else { t = t / eval; pos = new IPoint3D(); direction.Mult(t); pos = lineStart + direction; return(pos); } } }
public Plane3D(IVector3D n, IPoint3D b) { _a = n.X; _b = n.Y; _c = n.Z; _d = -(_a * b.X + _b * b.Y + _c * b.Z); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IMesh mesh = new IMesh(); List <Vector3d> vec = new List <Vector3d>(); List <int> eKey = new List <int>(); DA.GetData(0, ref mesh); DA.GetDataList(1, eKey); DA.GetDataList(2, vec); IMesh dM = mesh.DeepCopy(); ITopologicVertex v; IElement e; IVector3D T = new IVector3D(vec[0]); bool flag = eKey.Count.Equals(vec.Count); for (int i = 0; i < eKey.Count; i++) { e = dM.GetElementWithKey(eKey[i]); if (flag) { T = new IVector3D(vec[i]); } foreach (int vK in e.Vertices) { v = dM.GetVertexWithKey(vK); dM.SetVertexPosition(vK, v.Position + T); } } dM.UpdateGraphics(); DA.SetData(0, dM); }
public IVector3D Cross(IVector3D vec) { var xpart = (Vector3D)((Y * vec.Z - Z * vec.Y) * XUnit3D); var ypart = (Vector3D)((Z * vec.X - X * vec.Z) * YUnit3D); var zpart = (Vector3D)((X * vec.Y - Y * vec.X) * ZUnit3D); return((Vector3D)(xpart + ypart) + zpart); }
private void init(IMesh mesh) { count = mesh.Vertices.Count; A = new double[count]; B = new double[count]; nextA = new double[count]; nextB = new double[count]; coef = new double[count][]; double teta; IVector3D direction; for (int i = 0; i < count; i++) { int vK = mesh.VerticesKeys[i]; int[] vStart = mesh.Topology.GetVertexAdjacentVertices(vK); ITopologicVertex vertex = mesh.GetVertexWithKey(vK); A[i] = 1; B[i] = 0; coef[i] = new double[vStart.Length]; for (int j = 0; j < vStart.Length; j++) { ITopologicVertex neighbor = mesh.GetVertexWithKey(vStart[j]); direction = neighbor.Position - vertex.Position; teta = 1.0; if (AuxiliarVectorField != null && AuxiliarVectorField.Length > 0) { if (AuxiliarVectorField.Length == count) { teta = IVector3D.AngleBetween(direction, new IVector3D(AuxiliarVectorField[i])); } else { teta = IVector3D.AngleBetween(direction, new IVector3D(AuxiliarVectorField[0])); } } coef[i][j] = Math.Sqrt(Math.Sin(teta) * Math.Sin(teta) + Math.Pow(NeighborsContributionFactor, 2) * Math.Cos(teta) * Math.Cos(teta)); } } Random rnd = new Random(); for (int i = 0; i < RandomValuesPopulation; i++) { int idx = rnd.Next(0, count); for (int j = idx; j < idx + 10; j++) { A[j] = 1; B[j] = 1; } } }
private void txtDZ_EditValueChanged(object sender, EventArgs e) { if (this.m_CanDo) { IVector3D normalizedOriginOffset = this.m_pMarker3DSymbol.NormalizedOriginOffset; normalizedOriginOffset.ZComponent = (double)this.txtDZ.Value; this.m_pMarker3DSymbol.NormalizedOriginOffset = normalizedOriginOffset; this.refresh(e); } }
/// <summary> /// If translation is defined, returns matrix translated by the vector /// </summary> /// <param name="matrix">Input matrix</param> /// <param name="translation">Translation</param> /// <returns>Translated matrix</returns> private static XbimMatrix3D Translate(XbimMatrix3D matrix, IVector3D translation) { if (translation == null) { return(matrix); } var translationMatrix = XbimMatrix3D.CreateTranslation(translation.X, translation.Y, translation.Z); return(XbimMatrix3D.Multiply(matrix, translationMatrix)); }
public static Point3d ComputeAveragePoint(int[] keys, IMesh m) { IVector3D v = new IVector3D(); for (int i = 0; i < keys.Length; i++) { v += m.GetVertexWithKey(keys[i]).Position; } v /= keys.Length; return(new Point3d(v.X, v.Y, v.Z)); }
public override IGeometry CreateGeometry() { IPointCollection pointCollection = new PolygonClass(); IZAware zAware = pointCollection as IZAware; zAware.ZAware = true; IPoint point = new PointClass(); point.X = -_width / 2; point.Y = -_height / 2; point.Z = 0; pointCollection.AddPoint(point); point = new PointClass(); point.X = -_width / 2; point.Y = _height / 2; point.Z = 0; pointCollection.AddPoint(point); point = new PointClass(); point.X = _width / 2; point.Y = _height / 2; point.Z = 0; pointCollection.AddPoint(point); point = new PointClass(); point.X = _width / 2; point.Y = -_height / 2; point.Z = 0; pointCollection.AddPoint(point); ((IPolygon)pointCollection).Close(); IConstructMultiPatch patch = new MultiPatchClass(); patch.ConstructExtrude(_polyline.Length, pointCollection as IGeometry); IVector3D vectorZ = new Vector3DClass(); vectorZ.SetComponents(0, 0, 1); IVector3D vector3D = new Vector3DClass(); vector3D.SetComponents(_polyline.ToPoint.X - _polyline.FromPoint.X, _polyline.ToPoint.Y - _polyline.FromPoint.Y, _zdgc - _qdgc); double rotateAngle = Math.Acos(vector3D.ZComponent / vector3D.Magnitude); IVector3D vectorAxis = vectorZ.CrossProduct(vector3D) as IVector3D; ITransform3D transform3D = patch as ITransform3D; transform3D.RotateVector3D(vectorAxis, rotateAngle); transform3D.Move3D(_polyline.FromPoint.X, _polyline.FromPoint.Y, _qdgc); return(patch as IGeometry); }
internal static IPoint3D ComputesCatmullClarkVertexPosition(IMesh iM, int vKey) { ITopologicVertex v = iM.GetVertexWithKey(vKey); int[] vN = iM.Topology.GetVertexAdjacentVertices(vKey); int[] eN = iM.Topology.GetVertexIncidentElements(vKey); IVector3D barycenter = new IVector3D(); if (!iM.Topology.IsNakedVertex(vKey)) { int n = vN.Length; IVector3D P = new IVector3D(v.Position); P *= (n - 3); IVector3D R = new IVector3D(); foreach (int nKey in vN) { R += ComputeAveragePosition(new[] { vKey, nKey }, iM); } R /= vN.Length; R *= 2; IVector3D F = new IVector3D(); foreach (int nKey in eN) { F += ComputeAveragePosition(iM.GetElementWithKey(nKey).Vertices, iM); } F /= eN.Length; barycenter = F + R + P; barycenter /= n; } else { barycenter = new IVector3D(); int count = 0; foreach (int nKey in vN) { if (iM.Topology.IsNakedVertex(nKey)) { barycenter += ComputeAveragePosition(new[] { vKey, nKey }, iM); count++; } } barycenter /= count; } return(new IPoint3D(barycenter.X, barycenter.Y, barycenter.Z)); }
public static IMesh LaplacianSmoother(IMesh mesh, int smoothingSteps = 1, bool keepNaked = true, IEnumerable <int> exclude = default) { IMesh dM = mesh.DeepCopy(); ITopologicVertex v, nV; IVector3D pos; int[] nKeys; int count = 0; List <int> vKeys; if (exclude == default) { vKeys = dM.VerticesKeys; } else { vKeys = dM.VerticesKeys.Where(vK => !exclude.Any(p => p == vK)).ToList(); } while (count != smoothingSteps) { foreach (int vK in vKeys) { if (dM.Topology.IsNakedVertex(vK) && keepNaked == true) { continue; } v = dM.GetVertexWithKey(vK); nKeys = dM.Topology.GetVertexAdjacentVertices(vK); pos = new IVector3D(); foreach (int nK in nKeys) { nV = dM.GetVertexWithKey(nK); pos += nV.Position; } pos /= nKeys.Length; dM.SetVertexPosition(vK, new IPoint3D(pos.X, pos.Y, pos.Z)); } count++; } dM.UpdateGraphics(); return(dM); }
public void Mirror(IPlane plane) { IVector3D n = plane.Normal; IMatrix tensor = n.TensorProduct(n); double dot_plane = IVector3D.Dot(plane.Origin, n); double[][] data = new double[4][]; data[0] = new double[] { 1 - 2 * tensor.GetData(0, 0), -2 * tensor.GetData(0, 1), -2 * tensor.GetData(0, 2), 0 }; data[1] = new double[] { -2 * tensor.GetData(1, 0), 1 - 2 * tensor.GetData(1, 1), -2 * tensor.GetData(1, 2), 0 }; data[2] = new double[] { -2 * tensor.GetData(2, 0), -2 * tensor.GetData(2, 1), 1 - 2 * tensor.GetData(2, 2), 0 }; data[3] = new double[] { 2 * dot_plane * n.X, 2 * dot_plane * n.Y, 2 * dot_plane * n.Z, 1 }; IMatrix m = new IMatrix(data); TransformationMatrix = IMatrix.Mult(TransformationMatrix, m); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IMesh mesh = new IMesh(); Line ln = new Line(); double angle = 0; DA.GetData(0, ref mesh); DA.GetData(1, ref ln); DA.GetData(2, ref angle); Vector3d vec = ln.From - ln.To; IVector3D axis = new IVector3D(vec.X, vec.Y, vec.Z); IMesh dM = IModifier.Rotate(mesh, angle, new IPoint3D(ln.FromX, ln.FromY, ln.FromZ), axis); DA.SetData(0, dM); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { IMesh mesh = new IMesh(); Vector3d vec = Vector3d.ZAxis; Plane plane = Plane.WorldXY; double sCoef = 1; DA.GetData(0, ref mesh); DA.GetData(1, ref plane); DA.GetData(2, ref vec); DA.GetData(3, ref sCoef); IPlane pl = new IPlane(plane.OriginX, plane.OriginY, plane.OriginZ, plane.Normal.X, plane.Normal.Y, plane.Normal.Z); IVector3D dir = new IVector3D(vec.X, vec.Y, vec.Z); IMesh dM = IModifier.Skew(mesh, pl, dir, sCoef); DA.SetData(0, dM); }
public override IGeometry CreateGeometry() { IPointCollection pointCollection = new PolygonClass(); IZAware zAware = pointCollection as IZAware; zAware.ZAware = true; IPoint point = new PointClass(); point.X = -_width / 2; point.Y = -_length / 2; point.Z = 0; pointCollection.AddPoint(point); point = new PointClass(); point.X = -_width / 2; point.Y = _length / 2; point.Z = 0; pointCollection.AddPoint(point); point = new PointClass(); point.X = _width / 2; point.Y = _length / 2; point.Z = 0; pointCollection.AddPoint(point); point = new PointClass(); point.X = _width / 2; point.Y = -_length / 2; point.Z = 0; pointCollection.AddPoint(point); ((IPolygon)pointCollection).Close(); IConstructMultiPatch patch = new MultiPatchClass(); patch.ConstructExtrude(0 - _depth, pointCollection as IGeometry); ITransform3D transform3D = patch as ITransform3D; IVector3D vector3D = ConstructVector3D(0, 0, 1); transform3D.RotateVector3D(vector3D, _radian); transform3D.Move3D(_x, _y, _z); return(patch as IGeometry); }
public static IMesh Rotate(IMesh mesh, double angle, IPoint3D origin, IVector3D axis) { IMesh dup = mesh.DeepCopy(); ITransformX T; IPoint3D pt; foreach (int vK in dup.VerticesKeys) { pt = mesh.GetVertexWithKey(vK).Position; T = new ITransformX(); T.RotateAboutAxis(angle, origin, axis); pt.Transform(T); dup.SetVertexPosition(vK, pt); } dup.UpdateGraphics(); return(dup); }
private void FrmIllumination_Load(object sender, EventArgs e) { pScene = pscenecontrol.Scene; pSceneGraph = pScene.SceneGraph; pVector3D = pSceneGraph.SunVector; //lblAziumth.Text = pVector3D.Azimuth.ToString(); //lblaltitude.Text = pVector3D.Inclination.ToString(); //lblcontrast.Text = pSceneGraph.Contrast.ToString(); azimuth = pVector3D.Azimuth; altitude = pVector3D.Inclination; contrast = pSceneGraph.Contrast; ksAzimuth.Value = (decimal)getdegrees(pVector3D.Azimuth); ksAltitude.Value = (decimal)getdegrees(pVector3D.Inclination); trackcontrast.Value = pSceneGraph.Contrast; lblAziumth.Text = ksAzimuth.Value.ToString(); lblaltitude.Text = ksAltitude.Value.ToString(); lblcontrast.Text = trackcontrast.Value.ToString(); n++; }
/// <summary> /// 释放资源 /// </summary> public void Dispose() { if (flashTimer != null) { flashTimer.Stop(); flashTimer.Dispose(); } layer = null; lineSymbol = null; fillSymbol = null; graphicsLayer = null; isFlash = false; isHightlight = false; isVisible = false; upperAxisVector3D = null; normalVector3D = null; lowerAxisVector3D = null; geometryCollection = null; pointCollection = null; }
private void RotateGeometry(IMarker3DSymbol pSymbol, IVector3D pAxis, double dDegree) { if ((pAxis != null) && (dDegree != 0.0)) { IMarker3DPlacement placement = pSymbol as IMarker3DPlacement; IGeometry shape = placement.Shape; IEnvelope envelope = shape.Envelope; IPoint point = new PointClass { X = envelope.XMin + (envelope.XMax - envelope.XMin), Y = envelope.YMin + (envelope.YMax - envelope.YMin), Z = envelope.ZMin + (envelope.ZMax - envelope.ZMin) }; double rotationAngle = this.DegreesToRadians(dDegree); ITransform3D transformd = shape as ITransform3D; transformd.Move3D(-point.X, -point.Y, -point.Z); transformd.RotateVector3D(pAxis, rotationAngle); transformd.Move3D(point.X, point.Y, point.Z); } }
private IPoint[] BowditchAdjust(List <IVector3D> TraverseCourses, IPoint StartPoint, IPoint EndPoint, out IVector3D MiscloseVector, out double Ratio) { MiscloseVector = null; double dSUM = 0; Ratio = 10000; MiscloseVector = GetClosingVector(TraverseCourses, StartPoint, EndPoint, out dSUM) as IVector3D; //Azimuth of IVector3D is north azimuth radians zero degrees north if (MiscloseVector.Magnitude > 0.001) { Ratio = dSUM / MiscloseVector.Magnitude; } if (Ratio > 10000) { Ratio = 10000; } double dRunningSum = 0; IPoint[] TraversePoints = new IPoint[TraverseCourses.Count]; //from control for (int i = 0; i < TraverseCourses.Count; i++) { IPoint toPoint = new PointClass(); IVector3D vec = TraverseCourses[i]; dRunningSum += vec.Magnitude; double dScale = (dRunningSum / dSUM); double dXCorrection = MiscloseVector.XComponent * dScale; double dYCorrection = MiscloseVector.YComponent * dScale; toPoint.PutCoords(StartPoint.X + vec.XComponent, StartPoint.Y + vec.YComponent); StartPoint.PutCoords(toPoint.X, toPoint.Y); //re-set the start point to the one just added IPoint pAdjustedPoint = new PointClass(); pAdjustedPoint.PutCoords(toPoint.X - dXCorrection, toPoint.Y - dYCorrection); TraversePoints[i] = pAdjustedPoint; } return(TraversePoints); }
public static IMesh Stretch(IMesh mesh, IPlane plane = default, IVector3D direction = default, double stretchFactor = 1, double compressionFactor = 1) { if (plane == default) { plane = IPlane.WorldXY; } if (direction == default) { direction = plane.Normal; } IMesh dM = mesh.DeepCopy(); IPoint3D p; IVector3D vec; ITopologicVertex v; foreach (int vK in mesh.VerticesKeys) { v = dM.GetVertexWithKey(vK); double d = plane.DistanceToPlane(v.Position); if (d > 1e-9) { p = plane.GetClosestPoint(v.Position); vec = v.Position - p; vec *= stretchFactor; vec += p; p = GetClosestPointToFictiousLine(v.Position, plane.Origin, plane.Origin + direction); vec -= p; vec *= 1 / compressionFactor; vec += p; dM.SetVertexPosition(vK, vec.X, vec.Y, vec.Z); } } dM.UpdateGraphics(); return(dM); }
private static void DrawEnd(IGraphicsContainer3D endGraphicsContainer3D, IPoint endPoint, IVector3D axisOfRotationVector3D, double degreesOfRotation, IColor endColor, double endRadius) { IGeometry endGeometry = Vector3DExamples.GetExample2(); ITransform3D transform3D = endGeometry as ITransform3D; IPoint originPoint = GeometryUtilities.ConstructPoint3D(0, 0, 0); transform3D.Scale3D(originPoint, endRadius, endRadius, 2 * endRadius); if (degreesOfRotation != 0) { double angleOfRotationInRadians = GeometryUtilities.GetRadians(degreesOfRotation); transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians); } transform3D.Move3D(endPoint.X - originPoint.X, endPoint.Y - originPoint.Y, endPoint.Z - originPoint.Z); GraphicsLayer3DUtilities.AddMultiPatchToGraphicsLayer3D(endGraphicsContainer3D, endGeometry, endColor); }
public static IGeometry GetExample3() { const double DegreesOfRotation = 45; //Transform3D: Cylinder Rotated Around An Axis Via RotateVector3D() IGeometry geometry = Vector3DExamples.GetExample3(); //Construct A Vector3D Corresponding To The Desired Axis Of Rotation IVector3D axisOfRotationVector3D = GeometryUtilities.ConstructVector3D(0, 10, 0); //Obtain Angle Of Rotation In Radians double angleOfRotationInRadians = GeometryUtilities.GetRadians(DegreesOfRotation); ITransform3D transform3D = geometry as ITransform3D; transform3D.RotateVector3D(axisOfRotationVector3D, angleOfRotationInRadians); return(geometry); }
public Box3D(IPoint3D <T> point, IVector3D <T> vector) : this() { dynamic startWidth = point.X; dynamic endWidth = startWidth + vector.DeltaX; if (startWidth <= endWidth) { Width = new Interval <T>(startWidth, true, endWidth, true); } else { Width = new Interval <T>(endWidth, true, startWidth, true); } dynamic startHeight = point.Y; dynamic endHeight = startHeight + vector.DeltaY; if (startHeight <= endHeight) { Height = new Interval <T>(startHeight, true, endHeight, true); } else { Height = new Interval <T>(endHeight, true, startHeight, true); } dynamic startDepth = point.Z; dynamic endDepth = startDepth + vector.DeltaZ; if (startDepth <= endDepth) { Depth = new Interval <T>(startDepth, true, endDepth, true); } else { Depth = new Interval <T>(endDepth, true, startDepth, true); } }
public override void Load(IStream pstm) { //allocate a new vector 3D, no need to mess around with writing and reading... m_vector3D = new Vector3DClass(); base.Load(pstm); }
private IPoint[] BowditchAdjust(List<IVector3D> TraverseCourses, IPoint StartPoint, IPoint EndPoint, out IVector3D MiscloseVector, out double Ratio) { MiscloseVector = null; double dSUM = 0; Ratio = 10000; MiscloseVector = GetClosingVector(TraverseCourses, StartPoint, EndPoint, out dSUM) as IVector3D; //Azimuth of IVector3D is north azimuth radians zero degrees north if (MiscloseVector.Magnitude > 0.001) Ratio = dSUM / MiscloseVector.Magnitude; if (Ratio > 10000) Ratio = 10000; double dRunningSum = 0; IPoint[] TraversePoints = new IPoint[TraverseCourses.Count]; //from control for (int i = 0; i < TraverseCourses.Count; i++) { IPoint toPoint = new PointClass(); IVector3D vec = TraverseCourses[i]; dRunningSum += vec.Magnitude; double dScale = (dRunningSum / dSUM); double dXCorrection = MiscloseVector.XComponent * dScale; double dYCorrection = MiscloseVector.YComponent * dScale; toPoint.PutCoords(StartPoint.X + vec.XComponent, StartPoint.Y + vec.YComponent); StartPoint.PutCoords(toPoint.X, toPoint.Y); //re-set the start point to the one just added IPoint pAdjustedPoint = new PointClass(); pAdjustedPoint.PutCoords(toPoint.X - dXCorrection, toPoint.Y - dYCorrection); TraversePoints[i] = pAdjustedPoint; } return TraversePoints; }
public bool Contains(IVector3D p) { return (p.X >= m_Start.m_X) && (p.X < m_End.m_X) && (p.Y >= m_Start.m_Y) && (p.Y < m_End.m_Y) && (p.Z >= m_Start.m_Z) && (p.Z < m_End.m_Z); }
/// <summary> /// The class has only default CTor. /// </summary> public RSSWeatherLayer3DClass() : base() { m_sName = "RSSWeatherLayer3D"; m_vector3D = new Vector3DClass(); //set the bitmaps for the LayerInfo base.m_smallBitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream(GetType(), "Bitmaps.JaneSmall.bmp")); if (base.m_smallBitmap != null) { base.m_smallBitmap.MakeTransparent(base.m_smallBitmap.GetPixel(1, 1)); base.m_hSmallBitmap = m_smallBitmap.GetHbitmap(); } base.m_largeBitmap = new System.Drawing.Bitmap(GetType().Assembly.GetManifestResourceStream(GetType(), "Bitmaps.JaneLarge.bmp")); if (base.m_largeBitmap != null) { base.m_largeBitmap.MakeTransparent(base.m_largeBitmap.GetPixel(1, 1)); base.m_hLargeBitmap = m_largeBitmap.GetHbitmap(); } //get the directory for the layer's cache. If it does not exist, create it. string dir = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "WeatherIcons"); if (!System.IO.Directory.Exists(dir)) { System.IO.Directory.CreateDirectory(dir); } m_iconFolder = dir; //The cached data of the layer gets stored as XML m_weatherXmlFile = System.IO.Path.Combine(m_iconFolder, "Weather.xml"); //create the spatial reference for the layer (in this case WGS1984) m_spRef = CreateGeographicSpatialReference(); //initialize the layer's tables (main table as well as the textures table) InitializeTables(); //get the location list from a featureclass (US major cities) and synchronize it with the //cached information should it exists. if (null == m_locations) InitializeLocations(); //instantiate the timer for the weather update (to periodically update the //information against the RSS weather service) m_timer = new System.Timers.Timer(1000); m_timer.Enabled = false; m_timer.Elapsed += new ElapsedEventHandler(OnUpdateTimer); //initialize the redraw timer m_redrawTimer = new System.Timers.Timer(200); m_redrawTimer.Enabled = false; m_redrawTimer.Elapsed += new ElapsedEventHandler(OnRedrawUpdateTimer); //initialize the OpenGL matrices m_modelViewMatrix = new double[16]; m_billboardMatrix = new double[16]; m_projMatrix = new double[16]; m_viewport = new int[4]; }