private void Init() { var placement = _model.Get <Axis2Placement3D>(_surface.PointId); var cartesianPoint = _model.Get <CartesianPoint>(placement.PointIds[0]); var direction = _model.Get <DirectionPoint>(placement.PointIds[1]); var directionX = _model.Get <DirectionPoint>(placement.PointIds[2]); Points = new List <Vector3> { cartesianPoint.Vector }; var x = new Vector3(1, 0, 0); var y = new Vector3(0, 1, 0); var ax = Math.Acos(Vector3.Dot(direction.Vector, x) / (direction.Vector.Norm * x.Norm)); var ay = Math.Acos(Vector3.Dot(direction.Vector, y) / (direction.Vector.Norm * y.Norm)); var rotationMatrix = Matrix3x3.CreateFromYawPitchRoll((float)(Math.PI / 2 - ax), (float)(Math.PI / 2 - ay), 0); for (int i = 0; i < Sides; i++) { var angle = 360 - (i * 360d / Sides); angle = angle * 2 * Math.PI / 360d; // calculate point on unit circle and multiply by radius var vector = new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0) * (float)_surface.Radius; // change normal vector to direction vector vector = rotationMatrix * vector; // add midpoint position vector vector = vector + cartesianPoint.Vector; Points.Add(vector); } Indices = Enumerable.Range(1, Sides).Select(i => new int[] { 0, i, (i % Sides) + 1 }).SelectMany(d => d).ToList(); }
public void TestCircleCenter() { var circle = _model.Get <Circle>(98); var convertable = new CircleConvertable(circle, _model); Assert.AreEqual(new Vector3(70.0f, 3.70814490225E-014f, -53.0f), convertable.Points[0]); }
private void Init() { var s = _model.Get <CartesianPoint>(_line.Point1Id); var e = _model.Get <VectorPoint>(_line.Point2Id); var direction = _model.Get <DirectionPoint>(e.PointId); var endVector = s.Vector + direction.Vector * (float)e.Length; var x = new Vector3(1, 0, 0); var y = new Vector3(0, 1, 0); var ax = Math.Acos(Vector3.Dot(direction.Vector, x) / (direction.Vector.Norm * x.Norm)); var ay = Math.Acos(Vector3.Dot(direction.Vector, y) / (direction.Vector.Norm * y.Norm)); Points = new List <Vector3> { s.Vector }; var rotationMatrix = Matrix3x3.CreateFromYawPitchRoll((float)(Math.PI / 2 - ax), (float)(Math.PI / 2 - ay), 0); for (var i = 0; i < Sides; i++) { var angle = 360 - (i * 360d / Sides); angle = angle * 2 * Math.PI / 360d; // calculate point on unit circle and multiply by radius var vector = new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0) * (float)Thickness / 2; // change normal vector to direction vector vector = rotationMatrix * vector; // add midpoint position vector vector = vector + s.Vector; Points.Add(vector); } Points.Add(endVector); for (var i = 0; i < Sides; i++) { var angle = 360 - (i * 360d / Sides); angle = angle * 2 * Math.PI / 360d; // calculate point on unit circle and multiply by radius var vector = new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0) * (float)Thickness / 2; // change normal vector to direction vector vector = rotationMatrix * vector; // add midpoint position vector vector = vector + endVector; Points.Add(vector); } Indices = new List <int> { 0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 1, 5, 6, 7, 5, 7, 8, 5, 8, 9, 5, 9, 6, 1, 6, 7, 7, 2, 1, 2, 7, 8, 8, 3, 2, 3, 8, 9, 9, 4, 3, 4, 9, 6, 6, 1, 4 }; }
private void Init() { var bounds = _face.BoundIds.Select(_model.Get <Bound>); var surface = _model.Get <Surface>(_face.SurfaceId); var surfaceConvertable = new SurfaceConvertable(surface, _model); // create convertable for all faces and merge points and indices var convertables = bounds.Select(bound => new BoundConvertable(bound, _model)).Select(c => Tuple.New(c.Points, c.Indices)).ToList(); convertables.Add(Tuple.New(surfaceConvertable.Points, surfaceConvertable.Indices)); Points = convertables.Select(c => c.First).SelectMany(p => p).ToList(); Indices = convertables.Aggregate(Tuple.New(0, new List <int>()), Tuple.AggregateIndices).Second; }