예제 #1
0
        private CustomVertex.PositionColoredTextured[] CreateMesh(int meshPointCount)
        {
            int    upperBound  = meshPointCount - 1;
            float  scaleFactor = (float)1 / upperBound;
            double latrange    = this.North - this.South;
            double lonrange    = this.East - this.West;

            m_nVertices = meshPointCount * meshPointCount;

            CustomVertex.PositionColoredTextured[] vertices = new CustomVertex.PositionColoredTextured[meshPointCount * meshPointCount];

            for (int i = 0; i < meshPointCount; i++)
            {
                for (int j = 0; j < meshPointCount; j++)
                {
                    Vector3 pos = SMath.SphericalToCartesian(
                        this.North - scaleFactor * latrange * i,
                        this.West + scaleFactor * lonrange * j,
                        m_fRadius);

                    vertices[i * meshPointCount + j].X = pos.X;
                    vertices[i * meshPointCount + j].Y = pos.Y;
                    vertices[i * meshPointCount + j].Z = pos.Z;

                    vertices[i * meshPointCount + j].Tu = (float)j / meshPointCount;
                    vertices[i * meshPointCount + j].Tv = (float)i / meshPointCount;
                }
            }

            return(vertices);
        }
    private void UpdatePlayerTargetFromScreenInputPosition(Vector2 screenPosition)
    {
        if (Time.time - previousInputUpdateTime > InputRefreshRate)
        {
            float     inputPlaneWidth  = 40.0f;
            float     inputPlaneHeight = 40.0f;
            Vector2[] inputPoints      = SMath.GetDiscretePlanePointsFromCentrePoint(screenPosition, inputPlaneWidth, inputPlaneHeight, 10);
            if (PlayerObject != null)
            {
                PlayerController controller  = PlayerObject.GetComponent <PlayerController>();
                Vector2          screenPoint = screenPosition;
                for (int i = 0; i < inputPoints.Length; ++i)
                {
                    if (ScreenPointChangesPlayerTarget(inputPoints[i], controller))
                    {
                        return;
                    }
                }

                if (controller != null)
                {
                    controller.ClearTargetPosition();
                }
            }
            previousInputUpdateTime = Time.time;
        }
    }
예제 #3
0
        public BBox ShrinkAbsoluteBorder(Vector2d amount)
        {
            var dx = SMath.Clamp(amount.X, 0, 0.5 * Dx);
            var dy = SMath.Clamp(amount.Y, 0.0, 0.5 * Dy);

            return(new BBox(X0 + dx, Y0 + dy, X1 + dx, Y1 + dy));
        }
예제 #4
0
        protected virtual ImageTileInfo GetImageTileInfo(GeographicBoundingBox geoBox, int level)
        {
            int row = SMath.GetRowFromLatitude((geoBox.South + geoBox.North) / 2, geoBox.North - geoBox.South);
            int col = SMath.GetColFromLongitude((geoBox.West + geoBox.East) / 2, geoBox.North - geoBox.South);

            return(GetImageTileInfo(level, row, col));
        }
        private void movePlanets()
        {
            try
            {
                cleanForUpdate();
                double angleStep          = 0,
                       orbitalPeriodRatio = (route.ObjectOuter.OrbitalPeriod / route.ObjectInner.OrbitalPeriod);

                if (route.ObjectInner.ParentObjectIndex == route.ObjectFrom.ParentObjectIndex)
                {
                    angleStep   = (180 - route.DeparturePhaseAngle) / 190;
                    angleOuter += angleStep;
                    angleInner += angleStep * orbitalPeriodRatio;
                }
                else
                {
                    angleStep   = Math.Abs((route.DeparturePhaseAngle + 180 + Math.Truncate(route.Rotations) * 360) / 190);
                    angleOuter += angleStep / orbitalPeriodRatio;
                    angleInner += angleStep;
                }

                line1EndPoint      = SMath.FindNextPointByAngleAndDistance(centerPoint, innerRadius, angleInner);
                line2EndPoint      = SMath.FindNextPointByAngleAndDistance(centerPoint, outerRadius, angleOuter);
                innerPlanetPoint   = new Point(line1EndPoint.X - planetSize.Width / 2, line1EndPoint.Y - planetSize.Height / 2);
                outerPlanetPoint   = new Point(line2EndPoint.X - planetSize.Width / 2, line2EndPoint.Y - planetSize.Height / 2);
                InnerPlanet.Margin = new Thickness(innerPlanetPoint.X, innerPlanetPoint.Y, 0, 0);
                OuterPlanet.Margin = new Thickness(outerPlanetPoint.X, outerPlanetPoint.Y, 0, 0);
                this.DrawCanvas.Children.Add(InnerPlanet);
                this.DrawCanvas.Children.Add(OuterPlanet);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #6
0
    void StartGame()
    {
        grid = gridGameObject.GetComponent <IsometricQuadGrid>();

        List <SavableComponent> list = SaveLoadManager.Load();

        if (list != null)
        {
            for (int i = 0; i < list.Count; i++)
            {
                AddStructureBySaveData(list[i]);
            }
        }


        unplaceableMarker = Instantiate(unplaceableMarker);
        unplaceableMarker.SetActive(false);


        placeableMarker = Instantiate(placeableMarker);
        placeableMarker.SetActive(false);

        GridNode gridNode = grid.GetNodeByIndex(0, 0);

        Vector2 worldScale = SMath.GetWorldScale(gridNode.localSize, gridNode.parent);

        placerSize = (1 / placeableMarker.GetComponent <SpriteRenderer>().sprite.bounds.size.x) * worldScale;

        placeableMarker.transform.localScale = unplaceableMarker.transform.localScale = placerSize;

        SetGameStageByID(0);
        ArrangeLayouts();
    }
        protected override void Awake()
        {
            base.Awake();

            coneAngle = SMath.ClampDegree0To360(coneAngle);
            faceAngle = SMath.ClampDegree0To360(faceAngle);

            var meshFilter = GetComponent <MeshFilter>();

            if (meshFilter == null)
            {
                meshFilter = gameObject.AddComponent <MeshFilter>();
            }

            if (_mesh == null)
            {
                _mesh           = new Mesh();
                meshFilter.mesh = _mesh;
            }

            _losCamera = LOSManager.instance.losCamera;

            Vector2 screenSize = SHelper.GetScreenSizeInWorld(_losCamera.unityCamera);

            _raycastDistance = Mathf.Sqrt(screenSize.x * screenSize.x + screenSize.y * screenSize.y);
        }
예제 #8
0
        // OPT: This could prolly be more efficient.
        // But a core i5 handles 50k particles without much sweat, so, no sweat.
        public void Update(double dt, ParticleGroup group)
        {
            var fdt       = (float)dt;
            var particles = group.Particles;

            // We iterate downwards through the list so if we remove a particle we don't
            // reorder anything we haven't already updated.
            for (int i = particles.Count - 1; i > -1; i--)
            {
                var p = particles[i];

                if (scaleWithTime)
                {
                    p.Scale += (deltaScale * fdt);
                    p.Scale  = (float)SMath.Clamp(p.Scale, 0.1, 5);
                }
                if (changeColorWithTime)
                {
                    doColorFade(ref p, group.colorFader, fdt);
                    //group.colorFader.setColor(ref p);
                }

                doMovement(ref p, dt);
                particles[i] = p;
                if (p.Life < 0)
                {
                    group.Remove(i);
                }
            }
        }
예제 #9
0
 public static string GetStringParam(Entry arg, SMath.Math.Store context)
 {
     var dbl = GetNumberParam(arg, context).obj as SMath.Math.Numeric.TDouble;
     if (!dbl.isText)
         throw new SMath.Manager.MathException(Errors.ArgumentMustBeString);
     return dbl.ToString().Trim(Symbols.StringChar[0]);
 }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.BoundingSphere"/> class
        /// from a set of lat/lon values (degrees)
        /// </summary>
        public BoundingSphere(double south, double north, double west, double east, double radius1, double radius2)
        {
            // Compute the points in world coordinates
            Vector3d[] corners = new Vector3d[8];

            double scale = radius2 / radius1;

            corners[0] = SMath.SphericalToCartesianV3D(south, west, radius1);
            corners[1] = corners[0] * scale;
            corners[2] = SMath.SphericalToCartesianV3D(south, east, radius1);
            corners[3] = corners[2] * scale;
            corners[4] = SMath.SphericalToCartesianV3D(north, west, radius1);
            corners[5] = corners[4] * scale;
            corners[6] = SMath.SphericalToCartesianV3D(north, east, radius1);
            corners[7] = corners[6] * scale;

            //Find the center.  In this case, we'll simply average the coordinates.
            foreach (Vector3d v in corners)
            {
                Center += v;
            }
            Center *= 1.0 / 8.0;

            //Loop through the coordinates and find the maximum distance from the center.  This is the radius.
            foreach (Vector3d v in corners)
            {
                double distSq = (v - Center).LengthSq;
                if (distSq > RadiusSq)
                {
                    RadiusSq = distSq;
                }
            }
        }
예제 #11
0
파일: Attack.cs 프로젝트: stallboy/ReView
        public override bool OnUpdate(float inDeltaSeconds)
        {
            base.OnUpdate(inDeltaSeconds);

            if (Actor.Blackboard.Target != null)
            {
                Vector2 target = Actor.Blackboard.Target.Spatial.WorldPosition;

                float targetHeading = (float)Actor.Spatial.WorldPosition.AngleTo(target) * SMath.RAD2DEG;

                float headingDelta    = SMath.GetDeltaAngle(Actor.Spatial.WorldHeading, targetHeading);
                float headingToChange = Math.Sign(headingDelta) * Math.Min(Math.Abs(headingDelta), inDeltaSeconds * Actor.TurnSpeed);

                Turning = Math.Abs(headingToChange) > 10.0f;

                if (Turning)
                {
                    // Turn
                    Actor.Spatial.SetFacing(Actor.Spatial.WorldHeading + headingToChange);
                }
                else
                {
                    // Attack
                    Actor.Weapon.FireRequested = true;
                }

                DebugRenderer.Instance.Line(Actor.Spatial.WorldPosition, target, turning ? Color.Blue : Color.Red);
            }

            return(true);
        }
예제 #12
0
 public static string GetStringParam(Term[] arg, ref SMath.Math.Store context)
 {
   var dbl = GetNumberParam(arg, ref context).obj as SMath.Math.Numeric.TDouble;
   if (!dbl.isText)
     throw new SMath.Manager.EvaluationException(Errors.ArgumentMustBeString);
   return dbl.ToString().Trim('"');
 }
예제 #13
0
 /// <summary>
 /// Rescale frame buffer object.  If not given a power of 2 size,
 /// scales it up until it is.
 /// </summary>
 /// <param name="width">Screen width.</param>
 /// <param name="height">Screen height.</param>
 public void Resize(int width, int height)
 {
     width  = (int)SMath.RoundUpToPowerOf2(width);
     height = (int)SMath.RoundUpToPowerOf2(height);
     DestTexture1.ClearAndResize(width, height);
     DestTexture2.ClearAndResize(width, height);
 }
예제 #14
0
        private int GetElementCount(int time, bool transparent)
        {
            List <DebugRenderTriangleIndexMarker> triangleMarkers = transparent ? transparentTriangleMarkers : opaqueTriangleMarkers;

            int indexElementCount = 0;
            DebugRenderTriangleIndexMarker searchItem = new DebugRenderTriangleIndexMarker(0, time);
            int index = triangleMarkers.BinarySearch(searchItem);

            if (index < 0)
            {
                index = ~index;
            }

            index = triangleMarkers.Count > 0 ? SMath.Clamp(index, 0, triangleMarkers.Count - 1) : index;

            if (index < triangleMarkers.Count)
            {
                while (index > 0 && triangleMarkers[index].time > time)
                {
                    // Not exact match but the next one -> Decrease index by one to have only the range that counts up for the requested time
                    index--;
                }

                if (index < triangleMarkers.Count && triangleMarkers[index].time <= time)
                {
                    indexElementCount = triangleMarkers[index].index + 1;
                }
            }
            return(indexElementCount);
        }
예제 #15
0
        public static Texture RenderString(string s, Color4 color, int fontSize = 24)
        {
            var   textColor = Util.FromColor4(color);
            var   font      = new Font(FontFamily.GenericMonospace, fontSize, FontStyle.Bold);
            var   dummy     = new Bitmap(1, 1);
            SizeF size;

            using (var graphics = System.Drawing.Graphics.FromImage(dummy)) {
                // We need this stupid dummy drawing context because System.Drawing.Graphics is sorta lame and assumes
                // you never need to know how big a string is _before_ allocating memory for it.
                // The alternative is adding a dependency on Windows.Forms, so, forget that.
                size = graphics.MeasureString(s, font);
            }
            // BUGGO: This squishes the drawn text into a square shape no matter what shape it is!
            var pow2Width  = (int)SMath.RoundUpToPowerOf2(size.Width);
            var pow2Height = (int)SMath.RoundUpToPowerOf2(size.Height);
            var bitmap     = new Bitmap(pow2Width, pow2Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (var graphics = System.Drawing.Graphics.FromImage(bitmap)) {
                graphics.FillRectangle(new SolidBrush(Color.Transparent), 0, 0, pow2Width, pow2Height);
                graphics.DrawString(s, font, new SolidBrush(textColor), 0, 0);
                graphics.Flush();
            }
            return(new Texture(bitmap));
        }
예제 #16
0
        public void EvaluateTest()
        {
            var expression     = "2 + 3 *   10 - 4 / 2 +    4 * 3";
            var expectedResult = 42;
            var actualResult   = SMath.Evaluate(expression);

            Assert.AreEqual(expectedResult, actualResult);
        }
예제 #17
0
 public static LineArtVertex Lerp(LineArtVertex v0, LineArtVertex v1, double alpha, Vector2d?pos = null)
 {
     return(new LineArtVertex(
                pos ?? Vector2d.Lerp(v0.Pos, v1.Pos, alpha),
                color: SMath.Lerp(v0.Color, v1.Color, alpha),
                strokeWidth: SMath.Lerp(v0.StrokeWidth, v1.StrokeWidth, alpha)
                ));
 }
예제 #18
0
        private void CreateMesh()
        {
            double height = 0.5;
            double radius = 0.5;

            Segments = SMath.Clamp(Segments, 3, 256);

            VertexList = new VertexNormalColor[Segments * (CreateCaps ? 2 : 1) + 1];
            IndexList  = new uint[Segments * 3 + (CreateCaps ? (Segments - 2) * 3 : 0)];

            // Create vertices
            VertexList[0].Position = new Vector3(0, 0, height);
            for (int i = 0; i < Segments; i++)
            {
                double  angle            = ((double)i / (double)Segments) * Math.PI * 2.0;
                Vector2 planarCoordinate = Vector2.FromAngle(angle, radius);

                VertexList[i + 1].Position = new Vector3(planarCoordinate.X, planarCoordinate.Y, -height);

                if (CreateCaps)
                {
                    // Top (for cap)
                    VertexList[i + Segments + 1].Position = new Vector3(planarCoordinate.X, planarCoordinate.Y, -height);
                }
            }

            // Create normals
            Vector3 capNormal = CreateCaps ? GeometryMath.GetTriangleNormal(VertexList[1].Position, VertexList[2].Position, VertexList[3].Position) : new Vector3(0, 0, 0);

            for (int i = 0; i < Segments; i++)
            {
                Vector3 manifoldNormal = GeometryMath.GetTriangleNormal(VertexList[0].Position, VertexList[(i + 1) % Segments + 1].Position, VertexList[i + 1].Position);
                VertexList[i + 1].Normal = manifoldNormal;
                if (CreateCaps)
                {
                    VertexList[Segments + i + 1].Normal = capNormal;
                }
            }

            // Create triangles
            int index = 0;

            for (int i = 0; i < Segments; i++)
            {
                // Manifold
                IndexList[index++] = 0;
                IndexList[index++] = (uint)((i + 1) % Segments + 1);
                IndexList[index++] = (uint)(i + 1);

                if (CreateCaps && i < Segments - 2)
                {
                    // Cap
                    IndexList[index++] = (uint)(Segments + 1);
                    IndexList[index++] = (uint)(Segments + i + 2);
                    IndexList[index++] = (uint)(Segments + i + 3);
                }
            }
        }
예제 #19
0
 public void Evaluate_Static_API(string input, double variable, double expected)
 {
     SMath.SetValues(new VariablesCollection
     {
         ["b"] = 2,
         ["a"] = variable
     });
     Assert.AreEqual(expected, SMath.Evaluate(input));
 }
예제 #20
0
    void Update()
    {
        Vector3 direction = followObject.transform.position - transform.position;
        float   degree    = SMath.VectorToDegree(direction);

        transform.eulerAngles = new Vector3(0, 0, degree);  //get component losradial light and ste face angle to new angle.

        transform.position = Vector3.Lerp(transform.position, followObject.transform.position + Offset, Time.deltaTime * speed);
    }
예제 #21
0
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var param = coolpropPlugin.GetStringParam(value.Items[0], context);
            var Result = CoolPropDLLfunc(param);
            coolpropPlugin.LogInfo("[INFO]", "param = {0}, Result = {1}", param, Result);
            result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);

            return true;
        }
 public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
 {
     var param = coolpropPlugin.GetStringParam(value.Items[0], context);
     string resultStr;
     if (!CoolPropDLLfunc(param, out resultStr))
         coolpropPlugin.CoolPropError();
     result = coolpropPlugin.MakeStringResult(resultStr);
     return true;
 }
예제 #23
0
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var param = coolpropPlugin.GetStringParam(args[0], ref context);
      var Result = CoolPropDLLfunc(param);
      coolpropPlugin.LogInfo("[INFO ]", "param = {0}, Result = {1}", param, Result);
      result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);

      return true;
    }
예제 #24
0
 public ArcSegment(LineArtVertex v0, LineArtVertex v1, Vector2d center,
                   bool?clockwise = null, int?requestedSegments = null)
     : base(v0, v1)
 {
     Center    = center;
     Clockwise = clockwise ?? SMath.CrossZ(V0.Pos - Center, V1.Pos - Center) < 0;
     // XXX: Might be better to come up with something based on RADIANS_PER_PIECE
     // and the angle span of the arc.
     RequestedSegments = requestedSegments ?? DEFAULT_SEGMENTS;
 }
예제 #25
0
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      string FluidName = coolpropPlugin.GetStringParam(args[0], ref context),
             Output    = coolpropPlugin.GetStringParam(args[1], ref context);
      var Result = CoolPropDLLfunc(FluidName, Output);
      coolpropPlugin.LogInfo("[INFO ]", "FluidName = {0}, Output = {1}, Result = {2}", FluidName, Output, Result);
      result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(Output));

      return true;
    }
예제 #26
0
		public override void UpdatePreviousInfo () {
			base.UpdatePreviousInfo ();

			_previousFaceAngle = SMath.ClampDegree0To360(faceAngle);
			_previousLightAngle = SMath.ClampDegree0To360(coneAngle);
			_previousColor = color;
			_previousObstacleLayer = obstacleLayer;
			_previousInvertMode = invertMode;
			_previousDegreeStep = degreeStep;
		}
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var Ref = coolpropPlugin.GetStringParam(value.Items[0], context);
            var reference_state = coolpropPlugin.GetStringParam(value.Items[1], context);
            var Result = CoolPropDLLfunc(Ref, reference_state);
            coolpropPlugin.LogInfo("[INFO]", "Ref = {0}, reference_state = {1} Result = {2}", Ref, reference_state, Result);
            result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);

            return true;
        }
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var Ref = coolpropPlugin.GetStringParam(args[0], ref context);
      var reference_state = coolpropPlugin.GetStringParam(args[1], ref context);
      var Result = CoolPropDLLfunc(Ref, reference_state);
      coolpropPlugin.LogInfo("[INFO ]", "Ref = {0}, reference_state = {1} Result = {2}", Ref, reference_state, Result);
      result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);

      return true;
    }
예제 #29
0
 public PostprocPipeline(int width, int height)
 {
     this.width  = (int)SMath.RoundUpToPowerOf2(width);
     this.height = (int)SMath.RoundUpToPowerOf2(height);
     // Sanity checking.
     Log.Assert(Util.IsPowerOf2(this.width));
     Log.Assert(Util.IsPowerOf2(this.height));
     steps      = new List <IPostprocStep>();
     fboTexture = new Texture(this.width, this.height);
     fbo        = new FramebufferObject(fboTexture);
 }
예제 #30
0
        public void Resize(int width, int height)
        {
            var width2  = (int)SMath.RoundUpToPowerOf2(width);
            var height2 = (int)SMath.RoundUpToPowerOf2(height);

            fboTexture.ClearAndResize(width2, height2);
            foreach (var ppstep in steps)
            {
                ppstep.Resize(width2, height2);
            }
        }
예제 #31
0
        public void Arc(double cx, double cy, double radius, double sweep, Color4 color, double startAngle = 0.0,
                        int?numSegments = null)
        {
            var pos0 = SMath.Rotate(Vector2d.UnitX, startAngle) * radius;
            var pos1 = SMath.Rotate(Vector2d.UnitX, startAngle + sweep) * radius;
            //Log.Message("Start angle {0}, sweep {1}, radius {2}, pos0 {3}, pos1 {4}, length1 {5}, length2 {6}",
            //                  startAngle, sweep, radius, pos0, pos1, pos0.Length, pos1.Length);
            var v0 = new LineArtVertex(pos0, color: color);
            var v1 = new LineArtVertex(pos1, color: color);

            SubmitOpenPath(new ArcSegment(v1, v0, new Vector2d(cx, cy), true, numSegments));
        }
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var param = coolpropPlugin.GetStringParam(args[0], ref context);
      var output = new System.Text.StringBuilder(10000);
      var Result = CoolPropDLLfunc(param, output, output.Capacity);
      coolpropPlugin.LogInfo("[INFO ]", "param = {0} output = {1} Result = {2}", param, output.ToString(), Result);
      if (Result != 1)
        throw new EvaluationException(Errors.ArgumentDoesNotMatchToExpectedKind);
      result = coolpropPlugin.MakeStringResult(output.ToString());

      return true;
    }
예제 #33
0
		/// <summary>
		/// Checks the a particular degree is within cone area or not.
		/// </summary>
		/// <returns><c>true</c>, if degree is within cone areac>false</c> otherwise.</returns>
		/// <param name="degree">Degree.</param>
		public bool CheckDegreeWithinCone (float degree) {
			if (coneAngle == 0) return true;

			float min = faceAngle - coneAngle / 2;
			float max = faceAngle + coneAngle / 2;

			if (degree > max) {return false;}

			if (min < 0) {
				min = SMath.ClampDegree0To360(min);
			}
			return degree > min;
		}
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var fluid = coolpropPlugin.GetStringParam(value.Items[0], context);
            var param = coolpropPlugin.GetStringParam(value.Items[1], context);
            var output = new System.Text.StringBuilder(10000);
            var Result = CoolPropDLLfunc(fluid, param, output, output.Capacity);
            coolpropPlugin.LogInfo("[INFO]", "fluid = {0} param = {1} output = {2} Result = {3}", fluid, param, output.ToString(), Result);
            if (Result != 1)
                coolpropPlugin.CoolPropError();
            result = coolpropPlugin.MakeStringResult(output.ToString());

            return true;
        }
예제 #35
0
        // Works in counter-clock wise, pointA is the one with smaller angle against vector (1, 0)
        public List <Vector3> GetViewboxCornersBetweenPoints(Vector3 pointA, Vector3 pointB, Vector3 origin, bool give4CornersWhenAEqualB)
        {
            pointA.z = 0;
            pointB.z = 0;
            origin.z = 0;

            float degreeA = SMath.VectorToDegree(pointA - origin);
            float degreeB = SMath.VectorToDegree(pointB - origin);

            if (degreeA == 360)
            {
                degreeA = 0;
            }
            if (degreeA > degreeB + 0.0005f || (degreeA >= degreeB && degreeA <= degreeB + 0.0005f && give4CornersWhenAEqualB))                 // 0.0005f is the tolerance
            {
                degreeA -= 360;
            }

            Dictionary <float, Vector3> tempResults = new Dictionary <float, Vector3>();

            foreach (var line in viewbox)
            {
                Vector3 corner = line.end;

                float degreeToA    = 0;
                float degreeCorner = SMath.VectorToDegree(corner - origin);
                if (((degreeToA = (degreeCorner - degreeA)) > 0 && degreeCorner < degreeB) ||
                    ((degreeToA = (degreeCorner - 360 - degreeA)) > 0 && degreeCorner - 360 < degreeB) ||
                    ((degreeToA = (degreeCorner + 360 - degreeA)) > 0 && degreeCorner + 360 < degreeB))
                {
                    tempResults.Add(degreeToA, corner);
                }
            }

            List <float> degreesToA = new List <float>();

            foreach (float degreeToA in tempResults.Keys)
            {
                degreesToA.Add(degreeToA);
            }
            degreesToA.Sort();

            List <Vector3> results = new List <Vector3>();

            foreach (float degreeToA in degreesToA)
            {
                results.Add(tempResults[degreeToA]);
            }

            return(results);
        }
예제 #36
0
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            string FluidName = coolpropPlugin.GetStringParam(value.Items[0], context),
            Output    = coolpropPlugin.GetStringParam(value.Items[1], context);
            var Result = CoolPropDLLfunc(FluidName, Output);
            coolpropPlugin.LogInfo("[INFO]", "FluidName = {0}, Output = {1}, Result = {2}", FluidName, Output, Result);
            var ResUnit = Unit.Find(Output);
            // Props1SI may take parameters in either order; so, Output may actually be in FluidName
            if (ResUnit == Unit.unitless)
                ResUnit = Unit.Find(FluidName);
            result = coolpropPlugin.MakeDoubleResult(Result, ResUnit);

            return true;
        }
예제 #37
0
        /// <summary>
        /// Draws a tropic line at specified latitude with specified label
        /// </summary>
        /// <param name="latitude">Latitude in degrees</param>
        void RenderTropicLine(DrawArgs drawArgs, float latitude, string label)
        {
            int vertexIndex = 0;

            for (float longitude = MinVisibleLongitude; longitude <= MaxVisibleLongitude; longitude = longitude + LongitudeInterval)
            {
                if (LongitudeInterval == 10)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Vector3d p = SMath.SphericalToCartesianV3D(latitude, longitude + i, radius);
                        lineVertices[vertexIndex].X = (float)p.X;
                        lineVertices[vertexIndex].Y = (float)p.Y;
                        lineVertices[vertexIndex].Z = (float)p.Z;

                        lineVertices[vertexIndex].Color = World.Settings.TropicLinesColor.ToArgb();

                        vertexIndex++;
                    }
                    continue;
                }
                Vector3d pointXyz = SMath.SphericalToCartesianV3D(latitude, longitude, radius);

                lineVertices[vertexIndex].X     = (float)pointXyz.X;
                lineVertices[vertexIndex].Y     = (float)pointXyz.Y;
                lineVertices[vertexIndex].Z     = (float)pointXyz.Z;
                lineVertices[vertexIndex].Color = World.Settings.TropicLinesColor.ToArgb();
                vertexIndex++;
            }
            //TODO JHJ 10度线做了差值  9点
            if (LongitudeInterval == 10)
            {
                drawArgs.device.DrawUserPrimitives(PrimitiveType.LineStrip, LongitudePointCount * 10 - 1, lineVertices);
            }
            else
            {
                drawArgs.device.DrawUserPrimitives(PrimitiveType.LineStrip, LongitudePointCount - 1, lineVertices);
            }


            Vector3d t1 = SMath.SphericalToCartesianV3D(latitude,
                                                        drawArgs.WorldCamera.Longitude.Degrees - drawArgs.WorldCamera.TrueViewRange.Degrees * 0.3 * 0.5, radius);

            if (drawArgs.WorldCamera.ViewFrustum.ContainsPoint(t1))
            {
                t1 = drawArgs.WorldCamera.Project(t1);
                DrawArgs.Instance.DrawText(null, label, new System.Drawing.Rectangle((int)t1.X, (int)t1.Y, 640, 480), DrawTextFormat.Left, World.Settings.tropicLinesColor);
            }
        }
예제 #38
0
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            // Possible inputs:
            // "Omega"="HumRat"="W"        = Humidity ratio
            // "Tdp"="T_dp"="DewPoint"="D" = Dewpoint temperature
            // "Twb"="T_wb"="WetBulb"="B"  = Wet bulb temperature
            // "Enthalpy"="H"              = Enthalpy
            // "Entropy"="S"               = Entropy
            // "RH"="RelHum"="R"           = Relative humidity
            // "Tdb"="T_db"="T"            = Dry-bulb temperature
            // "P"                         = Pressure
            // "V"="Vda"                   = Volume of dry air
            // "mu"="Visc"="M"             = Viscosity
            // "k"="Conductivity"="K"      = Conductivity

            // Output:
            // "Vda"="V"[m^3/kg_da]
            // "Vha"[m^3/kg_ha]
            // "Y"[mol_w/mol]
            // "Hda"="H"
            // "Hha"[kJ/kg_ha]
            // "S"="Entropy"[kJ/kg_da]
            // "C"="cp"[kJ/kg_da]
            // "Cha"="cp_ha"[kJ/kg_da]
            // "Tdp"="D"[K]
            // "Twb"="T_wb"="WetBulb"="B"[K]
            // "Omega"="HumRat"="W"
            // "RH"="RelHum"="R"
            // "mu"="Visc"="M"
            // "k"="Conductivity"="K"

            var Output = coolpropPlugin.GetStringParam(value.Items[0], context);
            var Name1 = coolpropPlugin.GetStringParam(value.Items[1], context);
            var Prop1 = coolpropPlugin.GetNumberParam(value.Items[2], context);
            Unit.matchHA(Name1, Prop1, context);
            var Name2 = coolpropPlugin.GetStringParam(value.Items[3], context);
            var Prop2 = coolpropPlugin.GetNumberParam(value.Items[4], context);
            Unit.matchHA(Name2, Prop2, context);
            var Name3 = coolpropPlugin.GetStringParam(value.Items[5], context);
            var Prop3 = coolpropPlugin.GetNumberParam(value.Items[6], context);
            Unit.matchHA(Name3, Prop3, context);
            var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), Name3, Prop3.obj.ToDouble());
            coolpropPlugin.LogInfo("[INFO]",
                                   "Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, Name3 = {5}, Prop3 = {6}, Result = {7}",
                                   Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), Name3, Prop3.obj.ToDouble(), Result);
            result = coolpropPlugin.MakeDoubleResult(Result, Unit.FindHA(Output));

            return true;
        }
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var Ref = coolpropPlugin.GetStringParam(args[0], ref context);
      var T   = coolpropPlugin.GetNumberParam(args[1], ref context);
      var rho = coolpropPlugin.GetNumberParam(args[2], ref context);
      var h0  = coolpropPlugin.GetNumberParam(args[3], ref context);
      var s0  = coolpropPlugin.GetNumberParam(args[4], ref context);
      var Result = CoolPropDLLfunc(Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble());
      coolpropPlugin.LogInfo("[INFO ]",
        "Ref = {0} T = {1} rho = {2} h0 = {3} s0 = {4} Result = {5}",
        Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble(), Result);
      result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);

      return true;
    }
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var Ref = coolpropPlugin.GetStringParam(value.Items[0], context);
            var T   = coolpropPlugin.GetNumberParam(value.Items[1], context);
            var rho = coolpropPlugin.GetNumberParam(value.Items[2], context);
            var h0  = coolpropPlugin.GetNumberParam(value.Items[3], context);
            var s0  = coolpropPlugin.GetNumberParam(value.Items[4], context);
            var Result = CoolPropDLLfunc(Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble());
            coolpropPlugin.LogInfo("[INFO]",
                                   "Ref = {0} T = {1} rho = {2} h0 = {3} s0 = {4} Result = {5}",
                                   Ref, T.obj.ToDouble(), rho.obj.ToDouble(), h0.obj.ToDouble(), s0.obj.ToDouble(), Result);
            result = coolpropPlugin.MakeDoubleResult(Result, Unit.unitless);

            return true;
        }
예제 #41
0
		protected void UpdateUVs (Vector3[] vertices) {
			Vector2[] uvs = new Vector2[vertices.Length];

			for (int i=0; i<uvs.Length; i++) {
				float u = vertices[i].x / GetMaxLightLength() / 2 + 0.5f;
				float v = vertices[i].y / GetMaxLightLength() / 2 + 0.5f;
				
				u = SMath.Clamp(0, u, 1);
				v = SMath.Clamp(0, v, 1);

				uvs[i] = new Vector2(u, v);
			}

			_mesh.uv = uvs;
		}
예제 #42
0
        /// <summary>
        /// Checks the a particular degree is within cone area or not.
        /// </summary>
        /// <returns><c>true</c>, if degree is within cone areac>false</c> otherwise.</returns>
        /// <param name="degree">Degree.</param>
        public bool CheckDegreeWithinCone(float degree)
        {
            if (coneAngle == 0)
            {
                return(true);
            }

            float min = faceAngle - coneAngle / 2;
            float max = faceAngle + coneAngle / 2;

            var cc = 0;

            if (min < 0)
            {
                min = SMath.ClampDegree0To360(min);
                cc += 1;
            }

            if (max < 0)
            {
                max = SMath.ClampDegree0To360(max);
                cc += 2;
            }

            switch (cc)
            {
            case 0:
                return(degree > min && degree < max);

                break;

            case 1:
                return(degree > min || degree < max);

                break;

            case 2:
                return(degree > min && degree < max);

                break;

            case 3:
                return(degree > min && degree < max);

                break;
            }
            return(degree > min);
        }
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var fluid_name = coolpropPlugin.GetStringParam(args[0], ref context);
      var output     = coolpropPlugin.GetStringParam(args[1], ref context);
      var Q     = (int)coolpropPlugin.GetNumberParam(args[2], ref context).obj.ToDouble();
      var input      = coolpropPlugin.GetStringParam(args[3], ref context);
      var value      = coolpropPlugin.GetNumberParam(args[4], ref context);
      Unit.match(input, value, context);
      var Result = CoolPropDLLfunc(fluid_name, output, Q, input, value.obj.ToDouble());
      coolpropPlugin.LogInfo("[INFO ]",
        "fluid_name = {0}, output = {1}, Q = {2}, input = {3}, value = {4}, Result = {5}",
        fluid_name, output, Q, input, value.obj.ToDouble(), Result);
      result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(output));

      return true;
    }
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var fluid_name  = coolpropPlugin.GetStringParam(value.Items[0], context);
            var output      = coolpropPlugin.GetStringParam(value.Items[1], context);
            var Q           = (int)coolpropPlugin.GetNumberParam(value.Items[2], context).obj.ToDouble();
            var inputVar    = coolpropPlugin.GetStringParam(value.Items[3], context);
            var inputVal    = coolpropPlugin.GetNumberParam(value.Items[4], context);
            Unit.match(inputVar, inputVal, context);
            var Result = CoolPropDLLfunc(fluid_name, output, Q, inputVar, inputVal.obj.ToDouble());
            coolpropPlugin.LogInfo("[INFO]",
                                   "fluid_name = {0}, output = {1}, Q = {2}, input = {3}, value = {4}, Result = {5}",
                                   fluid_name, output, Q, inputVar, inputVal.obj.ToDouble(), Result);
            result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(output));

            return true;
        }
예제 #45
0
        public void UpdateViewingBox()
        {
            Vector2 screenSize = SHelper.GetScreenSizeInWorld(unityCamera);

            halfViewboxSize = screenSize / 2 * LOSManager.instance.viewboxExtension;

            Vector2 upperRight = new Vector2(halfViewboxSize.x, halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
            Vector2 upperLeft  = new Vector2(-halfViewboxSize.x, halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
            Vector2 lowerLeft  = new Vector2(-halfViewboxSize.x, -halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);
            Vector2 lowerRight = new Vector2(halfViewboxSize.x, -halfViewboxSize.y) + SMath.Vec3ToVec2(_trans.position);

            viewbox[0].SetStartEnd(lowerRight, upperRight);             // right
            viewbox[1].SetStartEnd(upperRight, upperLeft);              // up
            viewbox[2].SetStartEnd(upperLeft, lowerLeft);               // left
            viewbox[3].SetStartEnd(lowerLeft, lowerRight);              // down
        }
예제 #46
0
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var Output = coolpropPlugin.GetStringParam(args[0], ref context);
      var Name1 = coolpropPlugin.GetStringParam(args[1], ref context);
      var Prop1 = coolpropPlugin.GetNumberParam(args[2], ref context);
      Unit.match(Name1, Prop1, context);
      var Name2 = coolpropPlugin.GetStringParam(args[3], ref context);
      var Prop2 = coolpropPlugin.GetNumberParam(args[4], ref context);
      Unit.match(Name2, Prop2, context);
      var FluidName = coolpropPlugin.GetStringParam(args[5], ref context);
      var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName);
      coolpropPlugin.LogInfo("[INFO ]",
        "Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, FluidName = {5}, Result = {6}",
        Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, Result);
      result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(Output));

      return true;
    }
예제 #47
0
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var Output = coolpropPlugin.GetStringParam(value.Items[0], context);
            var Name1 = coolpropPlugin.GetStringParam(value.Items[1], context);
            var Prop1 = coolpropPlugin.GetNumberParam(value.Items[2], context);
            Unit.match(Name1, Prop1, context);
            var Name2 = coolpropPlugin.GetStringParam(value.Items[3], context);
            var Prop2 = coolpropPlugin.GetNumberParam(value.Items[4], context);
            Unit.match(Name2, Prop2, context);
            var FluidName = coolpropPlugin.GetStringParam(value.Items[5], context);
            var Result = CoolPropDLLfunc(Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName);
            coolpropPlugin.LogInfo("[INFO]",
                                   "Output = {0}, Name1 = {1}, Prop1 = {2}, Name2 = {3}, Prop2 = {4}, FluidName = {5}, Result = {6}",
                                   Output, Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, Result);

            result = coolpropPlugin.MakeDoubleResult(Result, Unit.Find(Output));

            return true;
        }
예제 #48
0
        private double FaceVariance(short v1, short v2, short v3)
        {
            double MaxVar = 0;

            if ((v1 - v2 <= 1 && v1 - v2 >= -1) || (v3 - v2 <= 1 && v3 - v2 >= -1) || v3 == v1)
            {
                MaxVar = 0; // minimal face, no variance
            }
            else
            {
                try
                {
                    // find vertice in middle of hypothenuse
                    short mid_hyp_indice = MidHypVerticeIndice(v1, v3);
                    // find real elevation in middle of hypothenuse
                    CustomVertex.PositionColoredTextured vh = this._elevatedVertices[mid_hyp_indice];
                    Vector3d v    = SMath.CartesianToSpherical((double)vh.X, (double)vh.Y, (double)vh.Z);
                    double   real = v.X - this._layerRadius;
                    // find extrapolated elevation in middle hyp.
                    double xe = (this._elevatedVertices[v1].X + this._elevatedVertices[v3].X) / 2;
                    double ye = (this._elevatedVertices[v1].Y + this._elevatedVertices[v3].Y) / 2;
                    double ze = (this._elevatedVertices[v1].Z + this._elevatedVertices[v3].Z) / 2;
                    v = SMath.CartesianToSpherical(xe, ye, ze);
                    double extrapolated = v.X - this._layerRadius;
                    // variance Note: could be done w/out MathEngine by computing raw cartesian distance
                    MaxVar = real - extrapolated;
                    // recurse for potential childs until unit face

                    if (v2 != v1 || mid_hyp_indice != v2 || v1 != v3)
                    {
                        MaxVar = Math.Max(MaxVar, FaceVariance(v2, mid_hyp_indice, v1));
                    }
                    if (v3 != v1 || mid_hyp_indice != v2 || v2 != v3)
                    {
                        MaxVar = Math.Max(MaxVar, FaceVariance(v3, mid_hyp_indice, v2));
                    }
                }
                catch
                {
                }
            }
            return(MaxVar);
        }
예제 #49
0
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            var Name1 = coolpropPlugin.GetStringParam(value.Items[0], context);
            var Prop1 = coolpropPlugin.GetNumberParam(value.Items[1], context);
            Unit.match(Name1, Prop1, context);
            var Name2 = coolpropPlugin.GetStringParam(value.Items[2], context);
            var Prop2 = coolpropPlugin.GetNumberParam(value.Items[3], context);
            Unit.match(Name2, Prop2, context);
            var FluidName = coolpropPlugin.GetStringParam(value.Items[4], context);
            var phase = new System.Text.StringBuilder(10000);
            var Result = CoolPropDLLfunc(Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase, phase.Capacity);
            coolpropPlugin.LogInfo("[INFO]",
                                   "Name1 = {0}, Prop1 = {1}, Name2 = {2}, Prop2 = {3}, FluidName = {4}, phase = {5}, Result = {6}",
                                   Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase.ToString(), Result);
            if (Result != 1)
                coolpropPlugin.CoolPropError();
            result = coolpropPlugin.MakeStringResult(phase.ToString());

            return true;
        }
예제 #50
0
    bool IFunction.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      var Name1 = coolpropPlugin.GetStringParam(args[0], ref context);
      var Prop1 = coolpropPlugin.GetNumberParam(args[1], ref context);
      Unit.match(Name1, Prop1, context);
      var Name2 = coolpropPlugin.GetStringParam(args[2], ref context);
      var Prop2 = coolpropPlugin.GetNumberParam(args[3], ref context);
      Unit.match(Name2, Prop2, context);
      var FluidName = coolpropPlugin.GetStringParam(args[4], ref context);
      var phase = new System.Text.StringBuilder(10000);
      var Result = CoolPropDLLfunc(Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase, phase.Capacity);
      coolpropPlugin.LogInfo("[INFO ]",
        "Name1 = {0}, Prop1 = {1}, Name2 = {2}, Prop2 = {3}, FluidName = {4}, phase = {5}, Result = {6}",
        Name1, Prop1.obj.ToDouble(), Name2, Prop2.obj.ToDouble(), FluidName, phase.ToString(), Result);
      if (Result != 1)
        throw new EvaluationException(Errors.ArgumentDoesNotMatchToExpectedKind);
      result = coolpropPlugin.MakeStringResult(phase.ToString());

      return true;
    }
예제 #51
0
 public static Term[] MakeDoubleResult(double result, SMath.Math.Symbolic.MItem unit)
 {
   var d = new SMath.Math.Numeric.TDouble(result);
   d.Units = unit;
   return d.ToTerms();
 }
예제 #52
0
파일: Unit.cs 프로젝트: saha84/CoolProp
 static void matchInternal(MItem unit, SMath.Math.Numeric.TNumber val, ref SMath.Math.Store context)
 {
   // First, reduce our units to basic representation to allow MathEqual()
   var t = SMath.Math.Decision.Preprocessing(unit.ToTerms(), ref context);
   var u = Expression.SimplifyEx(Converter.ToMItem(t), context);
   if (!val.obj.Units.MathEqual(u) && !val.obj.Units.MathEqual(unitless))
     throw new SMath.Manager.EvaluationException(SMath.Manager.Errors.UnitsDontMatch);
 }
예제 #53
0
        public bool TryEvaluateExpression(Entry value, SMath.Math.Store context, out Entry result)
        {
            result = null;

            if (value.Type != TermType.Function)
                return false;

            foreach (var func in functions)
            {
                if (!func.Info.Equals(value.ToTerm()))
                    continue;

                try
                {
                    return func.TryEvaluateExpression(value, context, out result);
                }
                catch (System.Exception ex)
                {
                    LogInfo("[ERROR]", "{0}({1}) {2}", value.Text, value.ArgsCount, ex.Message);
                    throw;
                }
            }

            return false;
        }
예제 #54
0
 public static SMath.Math.Numeric.TNumber GetNumberParam(Entry arg, SMath.Math.Store context)
 {
     //      var arg1 = SMath.Math.Decision.Preprocessing(arg, ref context);
     //      return SMath.Math.Numeric.Expression.Calculate(arg1, context).obj as SMath.Math.Numeric.TDouble;
     return SMath.Math.Decision.NumericCalculation(arg, context);
 }
예제 #55
0
    bool SMath.Math.IPluginLowLevelEvaluation.ExpressionEvaluation(Term root, Term[][] args, ref SMath.Math.Store context, ref Term[] result)
    {
      if (root.Type != TermType.Function)
        return false;

      foreach (var func in functions) {
        if (!func.Info.Equals(root))
          continue;

        try {
          return func.ExpressionEvaluation(root, args,ref context, ref result);
        }
        catch (System.Exception ex) {
          LogInfo("[ERROR]", "{0}({1}) {2}", root.Text, root.ChildCount, ex.Message);
          throw;
        }
      }

      return false;
    }
예제 #56
0
파일: Unit.cs 프로젝트: saha84/CoolProp
 public static void matchHA(string param, SMath.Math.Numeric.TNumber val, SMath.Math.Store context)
 {
   matchInternal(FindHA(param), val, ref context);
 }
예제 #57
0
        public static Entry MakeDoubleResult(double result, SMath.Math.Symbolic.MItem unit)
        {
            if (double.IsInfinity(result))
            {
                CoolPropError();
            }

            var d = new SMath.Math.Numeric.TDouble(result);
            d.Units = unit;
            return Entry.Create(d.ToTerms());
        }