public void SectionAngle6X4X1_2Returns_I_y() { SectionAngle angle = new SectionAngle("", 6, 4, 0.5, AngleRotation.FlatLegBottom, AngleOrientation.LongLegVertical); double I_y = angle.I_y; double refValue = 6.27; double actualTolerance = EvaluateActualTolerance(I_y, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public void SectionAngle6X4X1_2Returns_alpha() { SectionAngle angle = new SectionAngle("", 6, 4, 0.5, AngleRotation.FlatLegBottom, AngleOrientation.LongLegVertical); double alpha = angle.Angle_alpha; double refValue = 23.76; double actualTolerance = EvaluateActualTolerance(alpha, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public void SectionAngle6X4X1_2Returns_x_bar() { SectionAngle angle = new SectionAngle("", 6, 4, 0.5, AngleRotation.FlatLegBottom, AngleOrientation.LongLegVertical); double x_bar = angle.CentroidYAxisRect; double refValue = 0.9868; double actualTolerance = EvaluateActualTolerance(x_bar, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public void SectionAngle6X4X1_2Returns_y_bar() { SectionAngle angle = new SectionAngle("", 6, 4, 0.5, AngleRotation.FlatLegBottom, AngleOrientation.LongLegVertical); double y_bar = angle.y_Bar; double refValue = 1.987; double actualTolerance = EvaluateActualTolerance(y_bar, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public void SectionAngle6X4X1_2Returns_beta_w() { SectionAngle angle = new SectionAngle("", 6, 4, 0.5, AngleRotation.FlatLegBottom, AngleOrientation.LongLegVertical); double beta_w = angle.beta_w; double refValue = 3.14; double actualTolerance = EvaluateActualTolerance(beta_w, refValue); Assert.LessOrEqual(actualTolerance, tolerance); }
public ISliceableSection GetSliceableShape() { SectionAngle L = new SectionAngle("", this.d, this.b, this.t, this.AngleRotation, this.AngleOrientation); return(L); }
public static bool ComputeCameraMinorMajorAngle(Camera cam, ComputeCameraMinorMajorAngleOptions options, out SectionAngle angles) { const float raycastDistance = 512f; if (!cam) { angles = SectionAngle.Null; return(false); } Transform camTransform = cam.transform; Vector3 camPosition = camTransform.position; Vector3[] frustumCorners = new Vector3[4]; cam.CalculateFrustumCorners(new Rect(0, 0, 1, 1), cam.farClipPlane, Camera.MonoOrStereoscopicEye.Mono, frustumCorners); Vector3[] frustumCornersHit = new Vector3[4]; float[] minorAngles = new float[4]; float[] majorAngles = new float[4]; RaycastHit hit; for (int i = 0; i < frustumCorners.Length; ++i) { var worldSpaceCorner = camTransform.TransformPoint(frustumCorners[i]); Ray ray = new Ray(camPosition, (worldSpaceCorner - camPosition).normalized); if (!Physics.Raycast(ray, out hit, raycastDistance, options.landLayerMask)) { GameMain.ErrorTracking.Add("Fail to raycast mountain. See red ray from camera."); Debug.DrawLine(ray.origin, ray.origin + ray.direction * raycastDistance, Color.red); angles = SectionAngle.Null; return(false); } frustumCornersHit[i] = hit.point; Debug.DrawLine(camPosition, frustumCornersHit[i], Color.magenta); Torus.GetAngle(frustumCornersHit[i], out majorAngles[i], out minorAngles[i]); } var frustumCornersCenterHit = (frustumCornersHit[0] + frustumCornersHit[1] + frustumCornersHit[2] + frustumCornersHit[3]) * .25f; Debug.DrawLine(camPosition, frustumCornersCenterHit, Color.cyan); angles = SectionAngle.Null; return(false); // 0 => bottom-left // 1 => top-left // 2 => top-right // 3 => bottom-right float majorStart; float majorEnd; float minorStart; float minorEnd; Tools.GetStartEndAngle(majorAngles[1], majorAngles[2], out majorStart, out majorEnd); Tools.GetStartEndAngle(minorAngles[0], minorAngles[1], out minorStart, out minorEnd); Debug.Log($"minorStart:{minorStart} minorEnd:{minorEnd} majorStart:{majorStart} majorEnd:{majorEnd}"); majorStart -= options.majorPadding; majorEnd += options.majorPadding; minorStart -= options.minorPadding; minorEnd += options.minorPadding; angles.majorStart = Tools.Snap(majorStart, options.majorIncrement) % 360f; angles.majorEnd = Tools.Snap(majorEnd, options.majorIncrement) % 360f; angles.minorStart = Tools.Snap(minorStart, options.minorIncrement) % 360f; angles.minorEnd = Tools.Snap(minorEnd, options.minorIncrement) % 360f; angles.minorLength = (angles.minorEnd - angles.minorStart) % 360f; angles.majorLength = (angles.majorEnd - angles.majorStart) % 360f; return(true); }