/// <summary> /// Create a hue filter matrix using the given angle in degrees. /// </summary> /// <param name="degrees">The angle of rotation in degrees.</param> /// <returns>The <see cref="ColorMatrix"/></returns> public static ColorMatrix CreateHueFilter(float degrees) { // Wrap the angle round at 360. degrees %= 360; // Make sure it's not negative. while (degrees < 0) { degrees += 360; } float radian = GeometryUtilities.DegreeToRadian(degrees); float cosRadian = MathF.Cos(radian); float sinRadian = MathF.Sin(radian); // The matrix is set up to preserve the luminance of the image. // See http://graficaobscura.com/matrix/index.html // Number are taken from https://msdn.microsoft.com/en-us/library/jj192162(v=vs.85).aspx return(new ColorMatrix { M11 = .213F + (cosRadian * .787F) - (sinRadian * .213F), M21 = .715F - (cosRadian * .715F) - (sinRadian * .715F), M31 = .072F - (cosRadian * .072F) + (sinRadian * .928F), M12 = .213F - (cosRadian * .213F) + (sinRadian * .143F), M22 = .715F + (cosRadian * .285F) + (sinRadian * .140F), M32 = .072F - (cosRadian * .072F) - (sinRadian * .283F), M13 = .213F - (cosRadian * .213F) - (sinRadian * .787F), M23 = .715F - (cosRadian * .715F) + (sinRadian * .715F), M33 = .072F + (cosRadian * .928F) + (sinRadian * .072F), M44 = 1F }); }
private void CreateSelectionIndicators(RuntimeSurfaceGeometry surface, bool isfloor) { var vertices = surface.GetComponent <MeshCollider>().sharedMesh.vertices; var localToWorldMatrix = surface.transform.localToWorldMatrix; for (var i = 0; i < vertices.Length; i++) { var currentVertexWorldPosition = localToWorldMatrix.MultiplyPoint(vertices[i]); Vector3 previousVertexWorldPosition; Vector3 nextVertexWorldPosition; if (isfloor) { previousVertexWorldPosition = localToWorldMatrix.MultiplyPoint(vertices[i >= 1 ? i - 1 : vertices.Length - 1]); nextVertexWorldPosition = localToWorldMatrix.MultiplyPoint(vertices[i < vertices.Length - 1 ? i + 1 : 0]); } else { previousVertexWorldPosition = localToWorldMatrix.MultiplyPoint(vertices[i < vertices.Length - 1 ? i + 1 : 0]); nextVertexWorldPosition = localToWorldMatrix.MultiplyPoint(vertices[i >= 1 ? i - 1 : vertices.Length - 1]); } selectionVisualizationIndicators.Add(GeometryUtilities.CreateSurfaceSelectionIndicator($"Vertex ({i})", surface.transform, currentVertexWorldPosition, nextVertexWorldPosition, previousVertexWorldPosition)); } }
/// <summary> /// Registers the circle event created by the three parabolas as the directrix moves. /// </summary> /// <param name="shrinking">The parabola which is shrinking. This parabola is assigned the circle event.</param> /// <param name="left">The left parabola which will swallow the shrinking parabola</param> /// <param name="right">The right parabola which will swallow the shrinking parabola</param> private void RegisterCircleEvent(VParabolaNode left, VParabolaNode shrinking, VParabolaNode right) { if (left == null || right == null) { throw new ArgumentNullException("left or right"); } // check for conditions at which shrinking wouldn't be swallowed, return if that's the case if (shrinking.Site.Y.Within(left.Site.Y, double.Epsilon) && shrinking.Site.Y > right.Site.Y) { return; } if (shrinking.Site.Y.Within(right.Site.Y, double.Epsilon) && shrinking.Site.Y > left.Site.Y) { return; } // todo: left and right commons are already computed at Parabola Event, can steal from there? var leftCommon = (VEdgeNode)shrinking.GetRightParent(); var rightCommon = (VEdgeNode)shrinking.GetLeftParent(); // :: Find the intersection of the two edges which converge on the swallowed parabola // :: this will be the center of the circle event. var intersection = GeometryUtilities.FindNondegenerateIntersection( leftCommon.Site, leftCommon.Direction, rightCommon.Site, rightCommon.Direction ); var circleRadius = shrinking.Site.DistanceTo(intersection); var newEvent = new VCircleEvent(intersection, circleRadius, shrinking); m_queue.Add(newEvent); }
private void OnSceneGUI() { const float RADIUS = .2f; var transform = ((JHingeJoint)target).transform; var dir = transform.forward; var p1 = Body1 != null ? Body1.transform.position : transform.position; var p2 = Body2 != null ? p1 + dir * (Body2.transform.position - p1).magnitude : p1 + dir; var n1 = GeometryUtilities.GetArbitraryPerpendicular(dir) * RADIUS; var n2 = Vector3.Cross(dir, n1); var color = Handles.color; Handles.color = JPhysics.Color; { Handles.DrawLine(p1, p2); Handles.DrawWireDisc(p1, dir, RADIUS); Handles.DrawWireDisc(p2, dir, RADIUS); Handles.DrawLine(p1 - n1, p1 + n1); Handles.DrawLine(p1 - n2, p1 + n2); Handles.DrawLine(p2 - n1, p2 + n1); Handles.DrawLine(p2 - n2, p2 + n2); } Handles.color = color; }
public void LineDefinedByMovingEndPointsCrossesOrigin() { // parallel GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, -1).Sweep(new Vector(0, 2)), new Point(+1, -1).Sweep(new Vector(0, 2)) ).AssertEquals(new GeometryUtilities.IntersectionParameters { T = 0.5, S = 0.5 }); GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, -1).Sweep(new Vector(2, 0)), new Point(-1, +1).Sweep(new Vector(2, 0)) ).AssertEquals(new GeometryUtilities.IntersectionParameters { T = 0.5, S = 0.5 }); GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, -1).Sweep(new Vector(0.5, 0)), new Point(-1, +1).Sweep(new Vector(0.5, 0)) ).AssertEquals(null); // fixed GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, 0).Sweep(new Vector(0, 0)), new Point(+1, 0).Sweep(new Vector(0, 0)) ).AssertEquals(new GeometryUtilities.IntersectionParameters { T = 0, S = 0.5 }); GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, -1).Sweep(new Vector(0, 0)), new Point(+1, -1).Sweep(new Vector(0, 0)) ).AssertEquals(null); // orthogonal GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, +10).Sweep(new Vector(0, -11)), new Point(-1, -1).Sweep(new Vector(11, 0)) ).HasValue.AssertIsTrue(); GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, +3).Sweep(new Vector(0, -4)), new Point(-1, -1).Sweep(new Vector(4, 0)) ).AssertEquals(new GeometryUtilities.IntersectionParameters { T = 0.5, S = 0.5 }); GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, +1).Sweep(new Vector(0, -2)), new Point(-1, -1).Sweep(new Vector(2, 0)) ).AssertEquals(null); // anchored GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, 0).Sweep(new Vector(0, 0)), new Point(+1, -1).To(new Point(+1, +1)) ).AssertEquals(new GeometryUtilities.IntersectionParameters { T = 0.5, S = 0.5 }); GeometryUtilities.LineDefinedByMovingEndPointsCrossesOrigin( new Point(-1, 0).Sweep(new Vector(0, 0)), new Point(+1, -1).To(new Point(+1, -0.5)) ).AssertEquals(null); }
public void AppendSkewDegrees_WithSkewCenter( int width, int height, float degreesX, float degreesY, float cx, float cy, float x, float y) { var size = new Size(width, height); TBuilder builder = this.CreateBuilder(); var centerPoint = new Vector2(cx, cy); this.AppendSkewDegrees(builder, degreesX, degreesY, centerPoint); var matrix = Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), centerPoint); var position = new Vector2(x, y); var expected = Vector2.Transform(position, matrix); Vector2 actual = this.Execute(builder, new Rectangle(Point.Empty, size), position); Assert.Equal(actual, expected, Comparer); }
/// <summary> /// Gets and Sets the dynamic state of an asset in inertial coordinates at the given simulation time. /// This method overwrites any existing state data at simTime. /// If the dynamic state data does not exist at simTime, the value returned is a linear interpolation /// of existing data. /// </summary> /// <param name="simTime">The simulation time key</param> /// <returns>The inertial dynamic state date of the asset</returns> private Matrix <double> this[double simTime] { get { if (Type == DynamicStateType.STATIC_LLA) { // Set the JD associated with simTime double JD = simTime / 86400.0 + SimParameters.SimStartJD; return(GeometryUtilities.LLA2ECI(InitialConditions(), JD)); } else if (Type == DynamicStateType.STATIC_ECI) { return(InitialConditions()); } else if (Type == DynamicStateType.PREDETERMINED_ECI || Type == DynamicStateType.PREDETERMINED_LLA) { bool hasNotPropagated = _stateData.Count() == 1; if (hasNotPropagated) { PropagateState(SimParameters.SimEndSeconds); } Matrix <double> dynamicStateAtSimTime; if (!_stateData.TryGetValue(simTime, out dynamicStateAtSimTime)) { int lowerIndex = _stateData.Keys.LowerBoundIndex(simTime); int slopeInd = 1; if (simTime >= SimParameters.SimEndSeconds) { slopeInd = -1; } KeyValuePair <double, Matrix <double> > lowerData = _stateData.ElementAt(lowerIndex); KeyValuePair <double, Matrix <double> > upperData = _stateData.ElementAt(lowerIndex + slopeInd); double lowerTime = lowerData.Key; Matrix <double> lowerState = lowerData.Value; double upperTime = upperData.Key; Matrix <double> upperState = upperData.Value; Matrix <double> slope = (upperState - lowerState) / (upperTime - lowerTime); dynamicStateAtSimTime = slope * (simTime - lowerTime) + lowerState; } return(dynamicStateAtSimTime); } else { return(null); // TODO: Throw exception? } } set { _stateData[simTime] = value; } }
public void TestCenterOfMass(int testCaseNum, double expectedCenterOfMassX, double expectedCenterOfMassY) { GeometryUtilities utilities = new GeometryUtilities(); var actualCenterOfMass = utilities.CalculateCenterOfMass(PointsForCenterOfMassDictionary[testCaseNum]); Assert.LessOrEqual(Math.Abs(expectedCenterOfMassX - actualCenterOfMass.X), Epsilon); Assert.LessOrEqual(Math.Abs(expectedCenterOfMassY - actualCenterOfMass.Y), Epsilon); }
public void TestCalculateCartesianDistance(double x1, double y1, double x2, double y2, double expectedDistance) { var point1 = new Point(x1, y1); var point2 = new Point(x2, y2); var geometryUtilities = new GeometryUtilities(); var distance = geometryUtilities.CalculateCartesianDistance(point1, point2); Assert.LessOrEqual(Math.Abs(distance - expectedDistance), Epsilon); }
public static List <int> getSelectedBuildings(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius) { IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y); double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle)); double angle = (toAngle - fromAngle + 360) % 360; bool isCCW = true; if (angle > 180) { angle = 360 - angle; isCCW = false; } else if (angle == 0) { angle = 360; } double arcDistance = radius * GeometricUtilities.GetRadians(angle); IPoint fromPoint = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius); ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance); //逆时针 IPoint toPoint = circularArc.ToPoint; ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment; ISegment toSegment = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment; ISegment[] segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment }; IGeometryCollection polygon = GeometryUtilities.ConstructPolygon(segmentArray); IPolygon pPolygon = polygon as IPolygon; IGeometry pGeometry = GeometryUtilities.ConvertProjToGeo(pPolygon as IGeometry); IFeatureLayer pFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.Projecton) as IFeatureLayer; IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; ISpatialFilter spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = pGeometry; spatialFilter.GeometryField = pFeatureClass.ShapeFieldName; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; //Execute the spatialfilter IFeatureCursor featureCursor = pFeatureClass.Search(spatialFilter, false); IFeature pFeature = null; List <int> bids = new List <int>(); while ((pFeature = featureCursor.NextFeature()) != null) { bids.Add(pFeature.OID); } return(bids); }
public void DrawPolygon_Transformed <TPixel>(TestImageProvider <TPixel> provider) where TPixel : unmanaged, IPixel <TPixel> { PointF[] simplePath = { new Vector2(10, 10), new Vector2(200, 150), new Vector2(50, 300) }; provider.RunValidatingProcessorTest( c => c.SetDrawingTransform(Matrix3x2.CreateSkew(GeometryUtilities.DegreeToRadian(-15), 0, new Vector2(200, 200))) .DrawPolygon(Color.White, 2.5f, simplePath)); }
public static GameObject[] CreatePlayFieldFrame(Transform parent, Vector3 offset) { float x = 0.5F * cardWidth + fieldPadding; float z = 0.5F * cardHeight + fieldPadding; return(GeometryUtilities.CreateCylinderFrame(parent, new Vector3[4] { new Vector3(-x, 0.0F, -z) + offset, new Vector3(+x, 0.0F, -z) + offset, new Vector3(+x, 0.0F, +z) + offset, new Vector3(-x, 0.0F, +z) + offset, }, fieldThickness)); }
public override bool canPerform(Event proposedEvent, Universe environment) { if (!base.canPerform(proposedEvent, environment)) { return(false); } DynamicState position = Asset.AssetDynamicState; Matrix <double> assetPosECI = position.PositionECI(proposedEvent.GetTaskStart(Asset)); Matrix <double> targetPosECI = _task.Target.DynamicState.PositionECI(proposedEvent.GetTaskStart(Asset)); return(GeometryUtilities.hasLOS(assetPosECI, targetPosECI)); }
public override bool CanPerform(Event proposedEvent, Domain environment) { if (!base.CanPerform(proposedEvent, environment)) { return(false); } DynamicState position = Asset.AssetDynamicState; Vector assetPosECI = position.PositionECI(proposedEvent.GetTaskStart(Asset)); Vector targetPosECI = _task.Target.DynamicState.PositionECI(proposedEvent.GetTaskStart(Asset)); return(GeometryUtilities.hasLOS(assetPosECI, targetPosECI)); }
public void hasLOSTest() { Vector sat = new Vector(new List <double>(new double[] { 7378, 0, 0 })); Vector ground = new Vector(new List <double>(new double[] { -33.47, -70.65, 0 })); ground = GeometryUtilities.LLA2ECI(ground, 2457709); bool vector = GeometryUtilities.hasLOS(sat, ground); bool matrix = GeometryUtilities.hasLOS((Matrix <double>)sat, (Matrix <double>)ground); Assert.IsFalse(vector); Assert.IsFalse(matrix); }
public void Fill_RegularPolygon <TPixel>(TestImageProvider <TPixel> provider, int vertices, float radius, float angleDeg) where TPixel : struct, IPixel <TPixel> { float angle = GeometryUtilities.DegreeToRadian(angleDeg); var polygon = new RegularPolygon(100, 100, vertices, radius, angle); var color = Color.Yellow; FormattableString testOutput = $"V({vertices})_R({radius})_Ang({angleDeg})"; provider.RunValidatingProcessorTest( c => c.Fill(color, polygon), testOutput, appendSourceFileOrDescription: false, appendPixelTypeToFileName: false); }
private Vector4[] BuildUVs(short textureOffsetX, short textureOffsetY) { var meshUVs = new Vector4[polygonEntity.NativeObject.VertexCount]; for (var i = 0; i < polygonEntity.NativeObject.VertexCount; i++) { var vertexPosition = GeometryUtilities.GetMeshVertex(polygonEntity.ParentLevel.Level, polygonEntity.NativeObject.EndpointIndexes[i]); var u = -(vertexPosition.z * GeometryUtilities.MeterToWorldUnit); var v = -(vertexPosition.x * GeometryUtilities.MeterToWorldUnit); var floorOffset = new Vector4(textureOffsetY / GeometryUtilities.WorldUnitIncrementsPerWorldUnit, -textureOffsetX / GeometryUtilities.WorldUnitIncrementsPerWorldUnit, 0f, 0f); meshUVs[i] = new Vector4(u, v, lastLightIndex, lastTextureIndex) + floorOffset; } return(meshUVs); }
public void TestQuadraticFormula(double a, double b, double c, double?solution1, double?solution2) { GeometryUtilities utilities = new GeometryUtilities(); var quadraticFormulaSolutions = utilities.QuadraticFormula(a, b, c); if (solution1 == null) { Assert.AreEqual(quadraticFormulaSolutions.Count, 0); return; } if (solution2 == null) { Assert.AreEqual(quadraticFormulaSolutions.Count, 1); Assert.LessOrEqual(Math.Abs(solution1.Value - quadraticFormulaSolutions[0]), Epsilon); return; } Assert.AreEqual(quadraticFormulaSolutions.Count, 2); Assert.LessOrEqual(Math.Abs(solution1.Value - quadraticFormulaSolutions[0]), Epsilon); Assert.LessOrEqual(Math.Abs(solution2.Value - quadraticFormulaSolutions[1]), Epsilon); }
public void TestGetVertices(int numSides, int sideLength) { var geometryUtilities = new GeometryUtilities(); var polygon = new RegularPolygon(numSides, sideLength, new Point(0, 0), new Angle(0, MeasurementType.Radians)); var actualPoints = polygon.Vertices.ToArray(); var expectedPoints = numSidesToPointOrientationDictionary[numSides].ToArray(); Assert.AreEqual(expectedPoints.Length, actualPoints.Length); for (int i = 0; i < actualPoints.Length; i++) { Assert.LessOrEqual(Math.Abs(expectedPoints[0].Radians - actualPoints[0].Theta.Radians), Epsilon); Assert.LessOrEqual( Math.Abs(geometryUtilities.CalculateCartesianDistance(actualPoints[i], actualPoints[(i + 1) % numSides]) - 2), Epsilon ); Assert.LessOrEqual( Math.Abs(actualPoints[i].R - (double)sideLength / (2 * Math.Sin(Math.PI / (double)numSides))), Epsilon ); } }
public static void Main() { Console.WriteLine(GeometryUtilities.CalcTriangleArea(3, 4, 5)); Console.WriteLine(ArithmeticUtilities.NumberToDigit(5)); Console.WriteLine(ArithmeticUtilities.FindMax(5, -1, 3, 2, 14, 2, 3)); PrintUtilities.PrintNumber(1.3, 1); PrintUtilities.PrintPercent(0.75, 0); PrintUtilities.PrintAlignedNumber(2.30, 8); Console.WriteLine(GeometryUtilities.CalcDistance(3, -1, 3, 2.5)); Console.WriteLine("Horizontal? " + GeometryUtilities.IsHorizontalLine(3, -1, 3, 2.5)); Console.WriteLine("Vertical? " + GeometryUtilities.IsVerticallLine(3, -1, 3, 2.5)); Student peter = new Student("Peter", "Ivanov", "Sofia", new DateTime(1992, 3, 17)); Student stella = new Student("Stella", "Markova", "Vidin", new DateTime(1993, 11, 3)); Console.WriteLine("{0} older than {1} -> {2}", peter.FirstName, stella.FirstName, peter.IsOlderThan(stella)); }
void placeMenuCharacters() { BasesInfo = FindObjectOfType <BasesInfo>(); baseManager = FindObjectOfType <BaseManager>(); baseManager.ResetBaseManager(); BaseInfo[] baseInfos = BasesInfo.baseInfos; Vector3[] positions = GeometryUtilities.DivideCircleEquallyXZ(center.position, radius, baseInfos.Length, 0f); InputField[] inputFields = new InputField[baseInfos.Length]; characters = new Transform[baseInfos.Length]; for (int i = 0; i < baseInfos.Length; i++) { Quaternion lookAt = Quaternion.LookRotation(positions[i] - center.position); GameObject character = Instantiate(baseInfos[i].CharacterMenuPrefab, positions[i], lookAt); characters[i] = character.transform; InputField inputField = Instantiate(inputFieldPrefab, inputCanvas).GetComponent <InputField>(); inputField.SetGlobalBlackboard(baseInfos[i].GlobalBlackboard); baseInfos[i].GlobalBlackboard.ResetBlackBoard(); inputFields[i] = inputField; } inputFieldsController.SetInputFields(inputFields); GameGlobalBlackboard.Instance.ResetBlackBoard(); }
public static void drawSector(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius) { IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y); double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle)); double angle = (toAngle - fromAngle) % 360; bool isCCW = true; if (angle > 180) { angle = 360 - angle; isCCW = false; } if (angle == 0) { angle = 360; } double arcDistance = radius * GeometricUtilities.GetRadians(angle); IPoint fromPoint = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius); ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance); IPoint toPoint = circularArc.ToPoint; ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment; ISegment toSegment = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment; ISegment[] segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment }; IGeometryCollection polygon = GeometryUtilities.ConstructPolygon(segmentArray); //画扇形 IGraphicsContainer3D graphicsContainer3D = GISMapApplication.Instance.GetLayer(LayerNames.Rays) as IGraphicsContainer3D; IPolygonElement polygonElement = new PolygonElementClass(); IElement element = polygonElement as IElement; element.Geometry = polygon as IGeometry; graphicsContainer3D.AddElement(element); }
public override void ApplyPositionsAndTriangles() { var line = sideEntity.ParentLevel.Level.Lines[sideEntity.ParentLineIndex]; var endpointIndexA = sideEntity.IsClockwise ? line.EndpointIndexes[0] : line.EndpointIndexes[1]; var endpointIndexB = sideEntity.IsClockwise ? line.EndpointIndexes[1] : line.EndpointIndexes[0]; var bottomPosition = (short)(LowElevation - HighElevation); var positions = new Vector3[] { GeometryUtilities.GetMeshVertex(sideEntity.ParentLevel.Level, endpointIndexA, bottomPosition), GeometryUtilities.GetMeshVertex(sideEntity.ParentLevel.Level, endpointIndexA), GeometryUtilities.GetMeshVertex(sideEntity.ParentLevel.Level, endpointIndexB), GeometryUtilities.GetMeshVertex(sideEntity.ParentLevel.Level, endpointIndexB, bottomPosition) }; var triangles = new int[6]; triangles[0] = 0; triangles[1] = 1; triangles[2] = 2; triangles[3] = 2; triangles[4] = 3; triangles[5] = 0; SurfaceMesh.SetVertices(positions); SurfaceMesh.SetTriangles(triangles, submesh: 0); SurfaceMesh.RecalculateNormals(MeshUpdateFlags.DontNotifyMeshUsers | MeshUpdateFlags.DontRecalculateBounds | MeshUpdateFlags.DontResetBoneBounds); SurfaceMesh.RecalculateTangents(MeshUpdateFlags.DontNotifyMeshUsers | MeshUpdateFlags.DontRecalculateBounds | MeshUpdateFlags.DontResetBoneBounds); }
int createCharacters(int charactersPerCircle, float radius, float angleOffset) { int charactersNotPlaced = 0; while (nCharacters > 0) { charactersPerCircle = Mathf.Clamp(charactersPerCircle, 0, nCharacters); nCharacters -= charactersPerCircle; Vector3[] positions = GeometryUtilities.DivideCircleEquallyXZ(baseLocation, radius, charactersPerCircle, angleOffset); for (int i = 0; i < charactersPerCircle; i++) { if (!trySpawnCharacter(character, positions[i], baseLocation)) { charactersNotPlaced += 1; } } charactersPerCircle = (int)(charactersPerCircle * 1.25f); radius += 1.4f; angleOffset += 15f; } return(charactersNotPlaced); }
private void DrawTileLine(string id, Vector3Int start, Vector3Int end, bool draw) { int xMin = Mathf.Min(start.x, end.x); int xMax = Mathf.Max(start.x, end.x); int yMin = Mathf.Min(start.y, end.y); int yMax = Mathf.Max(start.y, end.y); if (draw) { PlaceTile(id, start); PlaceTile(id, end); } else { RemoveTile(id, start); RemoveTile(id, end); } for (int x = xMin; x < xMax + 1; x++) { for (int y = yMin; y < yMax + 1; y++) { if (GeometryUtilities.LineRect(start.x + 0.5f, start.y + 0.5f, end.x + 0.5f, end.y + 0.5f, x, y, 1, 1)) { if (draw) { PlaceTile(id, new Vector3Int(x, y, 0)); } else { RemoveTile(id, new Vector3Int(x, y, 0)); } } } } }
/// <summary> /// Prepends a rotation matrix using the given rotation in degrees at the given origin. /// </summary> /// <param name="degrees">The amount of rotation, in degrees.</param> /// <param name="origin">The rotation origin point.</param> /// <returns>The <see cref="AffineTransformBuilder"/>.</returns> public AffineTransformBuilder PrependRotationDegrees(float degrees, Vector2 origin) => this.PrependRotationRadians(GeometryUtilities.DegreeToRadian(degrees), origin);
/// <summary> /// Appends a centered skew matrix from the give angles in degrees. /// </summary> /// <param name="degreesX">The X angle, in degrees.</param> /// <param name="degreesY">The Y angle, in degrees.</param> /// <returns>The <see cref="ProjectiveTransformBuilder"/>.</returns> internal ProjectiveTransformBuilder AppendSkewDegrees(float degreesX, float degreesY) => this.AppendSkewRadians(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY));
/// <summary> /// Appends a centered rotation matrix using the given rotation in degrees. /// </summary> /// <param name="degrees">The amount of rotation, in degrees.</param> /// <returns>The <see cref="ProjectiveTransformBuilder"/>.</returns> public ProjectiveTransformBuilder AppendRotationDegrees(float degrees) => this.AppendRotationRadians(GeometryUtilities.DegreeToRadian(degrees));
/// <summary> /// Appends a skew matrix using the given angles in degrees at the given origin. /// </summary> /// <param name="degreesX">The X angle, in degrees.</param> /// <param name="degreesY">The Y angle, in degrees.</param> /// <param name="origin">The skew origin point.</param> /// <returns>The <see cref="ProjectiveTransformBuilder"/>.</returns> public ProjectiveTransformBuilder AppendSkewDegrees(float degreesX, float degreesY, Vector2 origin) => this.AppendSkewRadians(GeometryUtilities.DegreeToRadian(degreesX), GeometryUtilities.DegreeToRadian(degreesY), origin);
/// <summary> /// Appends a centered rotation matrix using the given rotation in degrees at the given origin. /// </summary> /// <param name="degrees">The amount of rotation, in radians.</param> /// <param name="origin">The rotation origin point.</param> /// <returns>The <see cref="ProjectiveTransformBuilder"/>.</returns> internal ProjectiveTransformBuilder AppendRotationDegrees(float degrees, Vector2 origin) => this.AppendRotationRadians(GeometryUtilities.DegreeToRadian(degrees), origin);