GraphFunctions 1.0.1.1

dotnet add package GraphFunctions --version 1.0.1.1
                    
NuGet\Install-Package GraphFunctions -Version 1.0.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GraphFunctions" Version="1.0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GraphFunctions" Version="1.0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="GraphFunctions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GraphFunctions --version 1.0.1.1
                    
#r "nuget: GraphFunctions, 1.0.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=GraphFunctions&version=1.0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=GraphFunctions&version=1.0.1.1
                    
Install as a Cake Tool

Graph Functions .NET Package Documentary


Description: Create your graph function by formula

Content:


GraphFunction Class

This class creates new graph function by Formula,
and then you can get Points

    public class GraphFunction
    {
        public string Formula { get; init; }
        public Vector2[] Points { get; init; }
    }
formula syntax :
    sum : +, substraction : -, multiplying : *, dividing : /, raise in power : ^ , sqrt : sqrt(number), sin : sin(number),  
    , asin : asin(number), , cos : cos(number), , acos : acos(number), cot : cot(number), tan : tan(number), atan : atan(number)  
    , acot : acot(number), sec : sec(number)

GraphFunction GetPoints

Returns the points of formula from minX to maxX , amount is freq, xSymbol that is symbol that displays x

        protected Vector2[] GetPoints(float minX, float maxX, int freq, char xSymbol = 'x')
        {
            if (string.IsNullOrEmpty(Formula) || maxX == minX) return [new Vector2()];
            if (maxX < minX) throw new ArgumentException("Max cannot be less then min");

            Vector2[] points = new Vector2[freq];
            double currentX = minX;
            CalculationEngine engine = new();

            for (int i = 0; i < freq; i++)
            {
                points[i] = GetPoint(engine, xSymbol, currentX);
                currentX += (maxX - minX) / (freq-1);
            }

            return points;
        }

Usage example:

    GraphFunction parabola = new GraphFunction("x^2" , 10, -10 ,10);
    foreach(var point in parabola.Points)
    {
        Console.WriteLine(point); we get 10 points of parabola
    }

LinearGraphFunction class

linear graph functions, has only two points and that's enough two build graph,

    public class LinearGraphFunction : GraphFunction
LinearGraphFunction GetPoints
        private Vector2[] GetPoints(float minX, float maxX,  char xSymbol)
        {
            if (string.IsNullOrEmpty(Formula) || maxX == minX) return [new Vector2()];
            if (maxX < minX) throw new ArgumentException("Max cannot be less then min");
            CalculationEngine engine = new();
            return [GetPoint(engine, xSymbol, minX), GetPoint(engine, xSymbol, maxX)];
        }

usage:

    var LinearGraphFunction linear = new LinearGraphFunction("-2 * x", -10 , 15);
    foreach(var point in linear.Points)
        Console.WriteLine(point);
    // we get {-10, 20}, {15, -30}
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1.1 142 4/27/2025
1.0.1 133 4/27/2025
1.0.0 92 4/26/2025

Feat: Linear GraphFunction, Fixed: bug with freq+1 points, rounding issue