public EllipsoidTangentPlane(Ellipsoid ellipsoid, IEnumerable<Vector3D> positions) { if (ellipsoid == null) { throw new ArgumentNullException("ellipsoid"); } if (positions == null) { throw new ArgumentNullException("positions"); } if (!CollectionAlgorithms.EnumerableCountGreaterThanOrEqual(positions, 1)) { throw new ArgumentOutOfRangeException("positions", "At least one position is required."); } AxisAlignedBoundingBox box = new AxisAlignedBoundingBox(positions); _origin = ellipsoid.ScaleToGeodeticSurface(box.Center); _normal = ellipsoid.GeodeticSurfaceNormal(_origin); _d = -_origin.Dot(_origin); _yAxis = _origin.Cross(_origin.MostOrthogonalAxis).Normalize(); _xAxis = _yAxis.Cross(_origin).Normalize(); }
public void Simple() { Vector3D min = new Vector3D(-1, -1, -1); Vector3D max = new Vector3D(1, 1, 1); IList<Vector3D> positions = new List<Vector3D>(); positions.Add(min); positions.Add(max); AxisAlignedBoundingBox box = new AxisAlignedBoundingBox(positions); Assert.AreEqual(min, box.Minimum); Assert.AreEqual(max, box.Maximum); Assert.AreEqual(Vector3D.Zero, box.Center); }
public RelativeToCenter(Context context, Vector3D[] positions, byte[] colors) { _sp = Device.CreateShaderProgram( EmbeddedResources.GetText("OpenGlobe.Examples.RelativeToCenter.Shaders.VS.glsl"), EmbeddedResources.GetText("OpenGlobe.Examples.Shaders.FS.glsl")); _modelViewPerspectiveMatrixRelativeToCenter = (Uniform<Matrix4F>)(_sp.Uniforms["u_modelViewPerspectiveMatrixRelativeToCenter"]); _pointSize = (Uniform<float>)_sp.Uniforms["u_pointSize"]; /////////////////////////////////////////////////////////////////// Mesh mesh = new Mesh(); VertexAttributeFloatVector3 positionsAttribute = new VertexAttributeFloatVector3("position", positions.Length); VertexAttributeRGB colorAttribute = new VertexAttributeRGB("color", positions.Length); mesh.Attributes.Add(positionsAttribute); mesh.Attributes.Add(colorAttribute); _center = new AxisAlignedBoundingBox(positions).Center; for (int i = 0; i < positions.Length; ++i) { positionsAttribute.Values.Add((positions[i] - _center).ToVector3F()); } for (int i = 0; i < colors.Length; ++i) { colorAttribute.Values.Add(colors[i]); } _va = context.CreateVertexArray(mesh, _sp.VertexAttributes, BufferHint.StaticDraw); /////////////////////////////////////////////////////////////////// RenderState renderState = new RenderState(); renderState.FacetCulling.Enabled = false; renderState.DepthTest.Enabled = false; renderState.ProgramPointSize = ProgramPointSize.Enabled; _drawState = new DrawState(renderState, _sp, _va); }
public void Empty() { AxisAlignedBoundingBox box = new AxisAlignedBoundingBox(new List<Vector3D>()); Assert.AreEqual(new Vector3D(double.MinValue, double.MinValue, double.MinValue), box.Minimum); Assert.AreEqual(new Vector3D(double.MaxValue, double.MaxValue, double.MaxValue), box.Maximum); }