public SphereCollider(GeometryShape geometry, Transform transform, float?radius = null, float offsetZ = 0.0f) : base(transform, geometry.Height) { radius ??= geometry.MajorRadius; Name = geometry.Name ?? ""; _offset = geometry.Offset; SphereBounds = new BoundingSphere(Vector3.Zero + new Vector3(0, 0, offsetZ), radius.Value); Update(transform); }
public BoxCollider(GeometryShape geometry, Transform transform) : base(geometry, transform) { var min = new Vector3(-geometry.MajorRadius, -geometry.MinorRadius, 0); var max = new Vector3(geometry.MajorRadius, geometry.MinorRadius, geometry.Height); _AABox = new AxisAlignedBoundingBox(min, max); SphereBounds = new BoundingSphere(Vector3.Zero + new Vector3(0, 0, geometry.Height / 2.0f), (max - min).Length() / 2.0f); Update(transform); }
public void DrawShape(GeometryShape geometryShape, int x, int y, int width, int height) { IShape shape = creator.CreateShape(geometryShape, x, y, width, height); if (shape != null) { shapes.Add(shape); } else { Debug.Assert(false); } }
public IShape CreateShape(GeometryShape geometryShape, int x, int y, int width, int height) { switch (geometryShape) { case GeometryShape.ELLIPSE: return(new Ellipse(x, y, width, height)); case GeometryShape.SQUARE: return(new Square(x, y, width, height)); default: Debug.Assert(false); return(null); } }
public void SphereColliderRectangleFIntersections(float x, float y, float radius, bool expected) { var rect = new RectangleF(0, 0, 6, 4); var transform = new Transform(new Vector3(x, y, 0), Quaternion.Identity); var geometryShape = new GeometryShape { Geometry = new Geometry(), Type = GeometryType.Sphere, Height = 10, MajorRadius = radius }; var collider = Collider.Create(geometryShape, transform); Assert.Equal(expected, collider.Intersects(rect)); }
private static IEnumerable <RadarRegionInfo> getRegions(SqlConnection con) { string sqlCmd = "select * from [DBT_FEATURE] where Type='LDZBQ'or Type='LDBWDQ'"; using (SqlDataAdapter sda = new SqlDataAdapter(sqlCmd, con)) { DataTable dt = new DataTable(); sda.Fill(dt); foreach (DataRow dr in dt.Rows) { string shape = dr["Shape"] as string; string name = dr["Name"] as string; string type = dr["Type"] as string; if (shape != null && name != null && type != null) { GeoAreaShape gas = null; try { gas = GeometryShape.Parse(shape) as GeoAreaShape; } catch { gas = null; } if (gas != null && gas.Polygon.Points.Count > 0) { string relatedRadar = string.Empty; object idObj = dr["Id"]; if (idObj is int) { relatedRadar = getRelatedRadar(con, (int)idObj); } RadarRegion region = new RadarRegion(); region.Name = name; region.Polygon = gas.Polygon.Points[0].Points.Select(pt => new Seecool.Radar.Unit.PointD(pt.X, pt.Y)).ToArray(); region.IsMask = type.ToUpper() == "LDZBQ"; region.ManualIdenfity = type.ToUpper() == "LDBWDQ"; yield return(new RadarRegionInfo(region, relatedRadar)); } } } } }
/// <summary> /// Initializes a new instance of the <see cref="Geometry" /> class in the Azure Cosmos DB service. /// </summary> /// <param name="type"> /// Geometry type. /// </param> /// <param name="geometryParams"> /// Coordinate reference system, additional properties etc. /// </param> protected Geometry(GeometryShape type, GeometryParams geometryParams) { if (geometryParams == null) { throw new ArgumentNullException("geometryParams"); } this.Type = type; if (geometryParams.Crs == null || geometryParams.Crs.Equals(Crs.Default)) { this.CrsForSerialization = null; } else { this.CrsForSerialization = geometryParams.Crs; } this.BoundingBox = geometryParams.BoundingBox; this.AdditionalProperties = geometryParams.AdditionalProperties ?? new Dictionary <string, object>(); }
private List <CompactFeatureObj> updateResult(List <tagFEATURE> list) { List <CompactFeatureObj> result = new List <CompactFeatureObj>(); for (int i = 0; i < list.Count; i++) { tagFEATURE feature = list[i]; GeometryShape geoShape = null; if ((feature.PRIM == GeoPrimitiveType.Point || feature.PRIM == GeoPrimitiveType.Text) && feature.SG2D != null) { geoShape = new GeoPointShape(feature.SG2D.Points[0].X, feature.SG2D.Points[0].Y); } else if (feature.PRIM == GeoPrimitiveType.Line && feature.SG2D != null) { geoShape = new GeoLineShape(feature.SG2D); } else if (feature.PRIM == GeoPrimitiveType.Area && feature.Area != null) { geoShape = new GeoAreaShape(feature.Area); } if (geoShape != null && _locator.Rect.IntersectsWith(geoShape.Bounds)) { string name = string.Empty; string[] names = feature.GetAttribute(S57AttributeType.NOBJNM); if (names != null && names.Length > 0) { name = names[0]; } string fileName = feature.File.Header.FileName; int tempIndex = fileName.LastIndexOf('\\') + 1; CompactFeatureObj obj = new CompactFeatureObj(string.Empty, name, string.Empty, geoShape, fileName.Substring(tempIndex, fileName.LastIndexOf('.') - tempIndex), feature.OBJL.ToString()); result.Add(obj); setAttribute(feature, obj); } } return(result); }
void Start() { shape = GetComponent <GeometryShape>(); OnSliderChanged(slider.value); }
public void DrawShape(GeometryShape geometryShape, int x, int y, int width, int height) { drawing.DrawShape(geometryShape, x, y, width, height); Invalidate(); }