/// <summary> /// Slope of the curve in local coordinates about the local origin that corresponds to the parametric coordinate given. /// </summary> /// <param name="relativePosition">The relative position, s. Relative position must be between 0 and 1.</param> /// <returns>System.Double.</returns> public virtual double SlopeByPosition(double relativePosition) { double xPrime = xPrimeByParameter(relativePosition); double yPrime = yPrimeByParameter(relativePosition); return(GeometryLibrary.SlopeParametric(xPrime, yPrime)); }
/// <summary> /// Slope of the curve in local coordinates about the local origin that corresponds to the parametric coordinate given. /// </summary> /// <param name="angleRadians">Parametric coordinate in radians.</param> /// <returns>System.Double.</returns> public virtual double SlopeByAngle(double angleRadians) { double xPrime = xPrimeByParameter(angleRadians); double yPrime = yPrimeByParameter(angleRadians); return(GeometryLibrary.SlopeParametric(xPrime, yPrime)); }
public static void Area(double magnitudeX1, double magnitudeY1, double magnitudeX2, double magnitudeY2, double expectedResult) { LineSegment segment1 = new LineSegment(new CartesianCoordinate(0, 0), new CartesianCoordinate(magnitudeX1, magnitudeY1)); LineSegment segment2 = new LineSegment(new CartesianCoordinate(0, 0), new CartesianCoordinate(magnitudeX2, magnitudeY2)); Assert.AreEqual(expectedResult, GeometryLibrary.Area(segment1, segment2)); }
/// <summary> /// Curvature of the curve in local coordinates about the local origin that corresponds to the parametric coordinate given. /// </summary> /// <param name="relativePosition">The relative position, s. Relative position must be between 0 and 1.</param> /// <returns>System.Double.</returns> public virtual double CurvatureByPosition(double relativePosition) { double xPrime = xPrimeByParameter(relativePosition); double yPrime = yPrimeByParameter(relativePosition); double xPrimeDouble = xPrimeDoubleByParameter(relativePosition); double yPrimeDouble = yPrimeDoubleByParameter(relativePosition); return(GeometryLibrary.CurvatureParametric(xPrime, yPrime, xPrimeDouble, yPrimeDouble)); }
public static void CurvatureImplicit( double Fx, double Fy, double Fxx, double Fxy, double Fyy, double expected) { double result = GeometryLibrary.CurvatureImplicit(Fx, Fy, Fxx, Fxy, Fyy); Assert.AreEqual(expected, result, Tolerance); }
[TestCase(1.1, 2.2, -2.1, -4.2, false)] // Sloped Pointing Opposite Way public static void IsConcave( double magnitudeX1, double magnitudeY1, double magnitudeX2, double magnitudeY2, bool expectedResult) { LineSegment segment1 = new LineSegment(new CartesianCoordinate(0, 0), new CartesianCoordinate(magnitudeX1, magnitudeY1)); LineSegment segment2 = new LineSegment(new CartesianCoordinate(0, 0), new CartesianCoordinate(magnitudeX2, magnitudeY2)); Assert.AreEqual(expectedResult, GeometryLibrary.IsConcave(segment1, segment2, Tolerance)); }
public static void CurvatureParametric( double xPrime, double yPrime, double xPrimeDouble, double yPrimeDouble, double expected) { double result = GeometryLibrary.CurvatureParametric(xPrime, yPrime, xPrimeDouble, yPrimeDouble); Assert.AreEqual(expected, result, Tolerance); }
[TestCase(1.1, 2.2, -2.1, -4.2, -1)] // Sloped Pointing Opposite Way public static void ConcavityCollinearity( double magnitudeX1, double magnitudeY1, double magnitudeX2, double magnitudeY2, double expectedResult) { LineSegment segment1 = new LineSegment(new CartesianCoordinate(0, 0), new CartesianCoordinate(magnitudeX1, magnitudeY1)); LineSegment segment2 = new LineSegment(new CartesianCoordinate(0, 0), new CartesianCoordinate(magnitudeX2, magnitudeY2)); Assert.AreEqual(expectedResult, GeometryLibrary.ConcavityCollinearity(segment1, segment2), Tolerance); }
public void UpdateInstanceData(FamilyInstance f) { instanceData.Transform = f.Transform; instanceData.HostId = f.HostId; this.transform.SetPosition(instanceData.Transform); if (instanceData.HostId != null) { host = GeometryLibrary.GetObject(instanceData.HostId); } #if UNITY_EDITOR this.ignoreNextDifference = this.transform.position != currentPostion || this.transform.rotation != currentRotation; #endif }
private IEnumerator UpdateHostGeometry(FamilyController behaviour, string hostId) { CoroutineWithData <Message> cd = new CoroutineWithData <Message>( behaviour, this.ServerRequestCoroutine(new Message { Type = "GET", Data = JsonConvert.SerializeObject(new { Id = hostId }) }) ); yield return(cd.coroutine); Message getResponse = cd.result; GeometryElement geo = JObject.Parse(getResponse.Data).ToObject <GeometryElement>(); GameObject obj = GeometryLibrary.GetObject(geo.Id); Helpers.MeshGenerator.ResetFaceMeshes(geo, obj); }
public static GameObject GenerateFaceMesh(Face f, GameObject parent) { Vector3[] vertices = f.Vertices.Select( v => new Vector3( (float)v.X * Helpers.Constants.M_PER_FT, (float)v.Z * Helpers.Constants.M_PER_FT, (float)v.Y * Helpers.Constants.M_PER_FT ) ).ToArray(); Vector2[] uvs = new Vector2[vertices.Length]; for (int i = 0; i < uvs.Length; i++) { uvs[i] = new Vector2(vertices[i].x, vertices[i].z); } Mesh msh = new Mesh(); msh.vertices = vertices; msh.triangles = f.Indices.ToList().ToArray().Reverse().ToArray(); msh.uv = uvs; msh.RecalculateNormals(); msh.RecalculateBounds(); GameObject newFace = new GameObject(); newFace.transform.position = Vector3.zero; newFace.transform.parent = parent.transform; newFace.name = $"Mesh Face"; newFace.gameObject.AddComponent(typeof(MeshRenderer)); ((MaterialFaceController)newFace.gameObject.AddComponent(typeof(MaterialFaceController))).LoadInstance(f); MeshFilter filter = newFace.gameObject.AddComponent(typeof(MeshFilter)) as MeshFilter; filter.mesh = msh; newFace.gameObject.AddComponent(typeof(MeshCollider)); MeshRenderer mr = newFace.GetComponent <MeshRenderer>(); mr.material = (UnityEngine.Material)UnityEngine.Resources.Load($"Default"); if (f.MaterialId != null && f.MaterialId != "-1") { var mat = MaterialLibrary.LookupMaterial("_" + f.MaterialId); if (mat != null) { mr.material = mat; newFace.name = $"_Mesh Face (_{f.MaterialId})"; } else { mat = MaterialLibrary.LookupMaterial(f.MaterialId); if (mat != null) { mr.material = mat; newFace.name = $"_Mesh Face ({f.MaterialId})"; } } } if (GeometryLibrary.GetObject(f.ElementId) == null) { GeometryLibrary.Add(f.ElementId, parent); } return(newFace); }
public static void SlopePolar(double thetaRadians, double radius, double radiusPrime, double expected) { double result = GeometryLibrary.SlopePolar(thetaRadians, radius, radiusPrime); Assert.AreEqual(expected, result, Tolerance); }
public static void SlopeGraph(double yPrime, double expected) { double result = GeometryLibrary.SlopeGraph(yPrime); Assert.AreEqual(expected, result, Tolerance); }
public static void CurvatureParametric_Throws_DivideByZeroException( double xPrime, double yPrime, double xPrimeDouble, double yPrimeDouble) { Assert.Throws <DivideByZeroException>(() => GeometryLibrary.CurvatureParametric(xPrime, yPrime, xPrimeDouble, yPrimeDouble)); }
public static void CurvaturePolar(double radius, double radiusPrime, double radiusPrimeDouble, double expected) { double result = GeometryLibrary.CurvaturePolar(radius, radiusPrime, radiusPrimeDouble); Assert.AreEqual(expected, result, Tolerance); }
public static void SlopeParametric(double xPrime, double yPrime, double expected) { double result = GeometryLibrary.SlopeParametric(xPrime, yPrime); Assert.AreEqual(expected, result, Tolerance); }
public static void CurvatureImplicit_Throws_DivideByZeroException( double Fx, double Fy, double Fxx, double Fxy, double Fyy) { Assert.Throws <DivideByZeroException>(() => GeometryLibrary.CurvatureImplicit(Fx, Fy, Fxx, Fxy, Fyy)); }
private IEnumerator LoadInstance(FamilyInstance f) { this.instanceData = f; this.InstanceData = Newtonsoft.Json.JsonConvert.SerializeObject(f); this.fam = FamilyLibrary.GetFamily(f.FamilyId); if (this.fam == null) { throw new System.Exception("Family " + f.FamilyId + " is not loaded"); } if (f.HostId != null) { this.host = GeometryLibrary.GetObject(f.HostId); } #if UNITY_EDITOR this.name = $"Family ({f.Id} - {this.fam.Tag} - {this.fam.ModelName ?? this.fam.FamilyName})"; #else this.name = f.Id; #endif // GameObject model = (GameObject)Resources.Load($"Families/{this.fam.Name}/model"); CoroutineWithData <object> cd = new CoroutineWithData <object>(this, FamilyLibrary.ResolveFamilyOBJ(f.FamilyId, f.VariantId)); yield return(cd.coroutine); object result = cd.result; if (result != null) { byte[] objData = cd.result as byte[]; // Debug.Log("PLACING FAMILY"); GameObject modelInstance; using (var textStream = new MemoryStream(objData)) { modelInstance = new OBJLoader().Load(textStream); } var initialRotation = modelInstance.transform.localRotation; modelInstance.transform.parent = this.transform; modelInstance.transform.localPosition = Vector3.zero; modelInstance.transform.localRotation = initialRotation; modelInstance.transform.localScale = new Vector3( Helpers.Constants.M_PER_FT, Helpers.Constants.M_PER_FT, Helpers.Constants.M_PER_FT ); foreach (var l in modelInstance.GetComponentsInChildren <Light>()) { l.gameObject.transform.rotation = Quaternion.LookRotation(Vector3.down); } foreach (UnityEngine.Transform child in transform) { foreach (UnityEngine.Transform geo in child) { var c = geo.GetComponent <FamilyGeometryController>(); if (c != null) { c.CollisionEnter += this.OnCollsionEnterEvent; c.CollisionExit += this.OnCollisionExitEvent; } } } // Debug.Log("Children " + count); } #if UNITY_EDITOR StartCoroutine(CheckForUpdate()); #endif }
public static void SlopeImplicit_Throws_DivideByZeroException(double Fx, double Fy) { Assert.Throws <DivideByZeroException>(() => GeometryLibrary.SlopeImplicit(Fx, Fy)); }
public static void SlopeImplicit(double Fx, double Fy, double expected) { double result = GeometryLibrary.SlopeImplicit(Fx, Fy); Assert.AreEqual(expected, result, Tolerance); }
public static void CurvaturePolar_Throws_DivideByZeroException(double radius, double radiusPrime, double radiusPrimeDouble) { Assert.Throws <DivideByZeroException>(() => GeometryLibrary.CurvaturePolar(radius, radiusPrime, radiusPrimeDouble)); }
public static void SlopeParametric_Throws_DivideByZeroException(double xPrime, double yPrime) { Assert.Throws <DivideByZeroException>(() => GeometryLibrary.SlopeParametric(xPrime, yPrime)); }
public static void SlopePolar_Throws_DivideByZeroException(double thetaRadians, double radius, double radiusPrime) { Assert.Throws <DivideByZeroException>(() => GeometryLibrary.SlopePolar(thetaRadians, radius, radiusPrime)); }