*Expired, please delete!*

*Expired, please delete. Thank you!*

Comments

  • I am so itching to make an XNA game myself and LOVE math handling classes, but am too busy with my current personal project, and work.

    You seem lite on requirements, unless you have these skill yourself (I'm bragging a bit in adding them)... What about extensions, functions (static procedures should not be called a method, methods operate on an instance not a class), enum, collections (more specific than lists), and exceptions? Also if you want multi-player; authentication protocols, multi-threading, data modeling, and database experiences.

    Why do you want Windows Forms and XNA experience, which platform are you developing this on?

    While BitConverter is nice, it doesn't test bits. Here is a class that will help you (and me) facilitate bit testing...

    [code]public static class Bit
    {
    public static uint And(string number1, string number2)
    {
    return (ToNumber(number1) & ToNumber(number2));
    }

    public static uint And(uint number1, uint number2)
    {
    return (number1 & number2);
    }

    public static uint Or(string number1, string number2)
    {
    return (ToNumber(number1) | ToNumber(number2));
    }

    public static uint Or(uint number1, uint number2)
    {
    return (number1 | number2);
    }

    public static uint XOr(string number1, string number2)
    {
    return (ToNumber(number1) ^ ToNumber(number2));
    }

    public static uint XOr(uint number1, uint number2)
    {
    return (number1 ^ number2);
    }

    public static uint Not(string number)
    {
    return (~ToNumber(number));
    }

    public static uint Not(uint number)
    {
    return (~number);
    }

    public static uint LeftShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) << numberOfDigits);
    }

    public static uint LeftShift(uint number, int numberOfDigits)
    {
    return (number << numberOfDigits);
    }

    public static uint RightShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) >> numberOfDigits);
    }

    public static uint RightShift(uint number, int numberOfDigits)
    {
    return (number >> numberOfDigits);
    }

    public static bool TestBit(string number, int bitPosition)
    {
    return ((ToNumber(number) & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static bool TestBit(uint number, int bitPosition)
    {
    return ((number & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static uint ClearBitmask(string number, string mask)
    {
    return ClearBit(ToNumber(number), ToNumber(mask));
    }

    public static uint ClearBitmask(uint number, uint mask)
    {
    return ClearBit(number, mask);
    }

    public static uint SetBitmask(string number, string mask)
    {
    return SetBit(ToNumber(number), ToNumber(mask));
    }

    public static uint SetBitmask(uint number, uint mask)
    {
    return SetBit(number, mask);
    }

    public static byte SetBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static byte ClearBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint SetBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint ClearBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static string ToBinary(string number)
    {
    return ToBinary(ToNumber(number));
    }

    public static string ToBinary(uint number)
    {
    try
    {
    return Convert.ToString(number, 2);
    }
    catch
    {
    return "0";
    }
    }

    public static uint ToValue(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString, 2);
    }
    catch
    {
    return 0;
    }
    }

    public static uint ToNumber(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString);
    }
    catch
    {
    return 0;
    }
    }
    }[/code]
  • I am so itching to make an XNA game myself and LOVE math handling classes, but am too busy with my current personal project, and work.

    You seem lite on requirements, unless you have these skill yourself (I'm bragging a bit in adding them)... What about extensions, functions (static procedures should not be called a method, methods operate on an instance not a class), enum, collections (more specific than lists), and exceptions? Also if you want multi-player; authentication protocols, multi-threading, data modeling, and database experiences.

    Why do you want Windows Forms and XNA experience, which platform are you developing this on?

    While BitConverter is nice, it doesn't test bits. Here is a class that will help you (and me) facilitate bit testing...

    [code]public static class Bit
    {
    public static uint And(string number1, string number2)
    {
    return (ToNumber(number1) & ToNumber(number2));
    }

    public static uint And(uint number1, uint number2)
    {
    return (number1 & number2);
    }

    public static uint Or(string number1, string number2)
    {
    return (ToNumber(number1) | ToNumber(number2));
    }

    public static uint Or(uint number1, uint number2)
    {
    return (number1 | number2);
    }

    public static uint XOr(string number1, string number2)
    {
    return (ToNumber(number1) ^ ToNumber(number2));
    }

    public static uint XOr(uint number1, uint number2)
    {
    return (number1 ^ number2);
    }

    public static uint Not(string number)
    {
    return (~ToNumber(number));
    }

    public static uint Not(uint number)
    {
    return (~number);
    }

    public static uint LeftShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) << numberOfDigits);
    }

    public static uint LeftShift(uint number, int numberOfDigits)
    {
    return (number << numberOfDigits);
    }

    public static uint RightShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) >> numberOfDigits);
    }

    public static uint RightShift(uint number, int numberOfDigits)
    {
    return (number >> numberOfDigits);
    }

    public static bool TestBit(string number, int bitPosition)
    {
    return ((ToNumber(number) & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static bool TestBit(uint number, int bitPosition)
    {
    return ((number & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static uint ClearBitmask(string number, string mask)
    {
    return ClearBit(ToNumber(number), ToNumber(mask));
    }

    public static uint ClearBitmask(uint number, uint mask)
    {
    return ClearBit(number, mask);
    }

    public static uint SetBitmask(string number, string mask)
    {
    return SetBit(ToNumber(number), ToNumber(mask));
    }

    public static uint SetBitmask(uint number, uint mask)
    {
    return SetBit(number, mask);
    }

    public static byte SetBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static byte ClearBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint SetBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint ClearBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static string ToBinary(string number)
    {
    return ToBinary(ToNumber(number));
    }

    public static string ToBinary(uint number)
    {
    try
    {
    return Convert.ToString(number, 2);
    }
    catch
    {
    return "0";
    }
    }

    public static uint ToValue(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString, 2);
    }
    catch
    {
    return 0;
    }
    }

    public static uint ToNumber(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString);
    }
    catch
    {
    return 0;
    }
    }
    }[/code]
  • I am so itching to make an XNA game myself and LOVE math handling classes, but am too busy with my current personal project, and work.

    You seem lite on requirements, unless you have these skill yourself (I'm bragging a bit in adding them)... What about extensions, functions (static procedures should not be called a method, methods operate on an instance not a class), enum, collections (more specific than lists), and exceptions? Also if you want multi-player; authentication protocols, multi-threading, data modeling, and database experiences.

    Why do you want Windows Forms and XNA experience, which platform are you developing this on?

    While BitConverter is nice, it doesn't test bits. Here is a class that will help you (and me) facilitate bit testing...

    [code]public static class Bit
    {
    public static uint And(string number1, string number2)
    {
    return (ToNumber(number1) & ToNumber(number2));
    }

    public static uint And(uint number1, uint number2)
    {
    return (number1 & number2);
    }

    public static uint Or(string number1, string number2)
    {
    return (ToNumber(number1) | ToNumber(number2));
    }

    public static uint Or(uint number1, uint number2)
    {
    return (number1 | number2);
    }

    public static uint XOr(string number1, string number2)
    {
    return (ToNumber(number1) ^ ToNumber(number2));
    }

    public static uint XOr(uint number1, uint number2)
    {
    return (number1 ^ number2);
    }

    public static uint Not(string number)
    {
    return (~ToNumber(number));
    }

    public static uint Not(uint number)
    {
    return (~number);
    }

    public static uint LeftShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) << numberOfDigits);
    }

    public static uint LeftShift(uint number, int numberOfDigits)
    {
    return (number << numberOfDigits);
    }

    public static uint RightShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) >> numberOfDigits);
    }

    public static uint RightShift(uint number, int numberOfDigits)
    {
    return (number >> numberOfDigits);
    }

    public static bool TestBit(string number, int bitPosition)
    {
    return ((ToNumber(number) & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static bool TestBit(uint number, int bitPosition)
    {
    return ((number & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static uint ClearBitmask(string number, string mask)
    {
    return ClearBit(ToNumber(number), ToNumber(mask));
    }

    public static uint ClearBitmask(uint number, uint mask)
    {
    return ClearBit(number, mask);
    }

    public static uint SetBitmask(string number, string mask)
    {
    return SetBit(ToNumber(number), ToNumber(mask));
    }

    public static uint SetBitmask(uint number, uint mask)
    {
    return SetBit(number, mask);
    }

    public static byte SetBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static byte ClearBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint SetBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint ClearBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static string ToBinary(string number)
    {
    return ToBinary(ToNumber(number));
    }

    public static string ToBinary(uint number)
    {
    try
    {
    return Convert.ToString(number, 2);
    }
    catch
    {
    return "0";
    }
    }

    public static uint ToValue(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString, 2);
    }
    catch
    {
    return 0;
    }
    }

    public static uint ToNumber(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString);
    }
    catch
    {
    return 0;
    }
    }
    }[/code]
  • I am so itching to make an XNA game myself and LOVE math handling classes, but am too busy with my current personal project, and work.

    You seem lite on requirements, unless you have these skill yourself (I'm bragging a bit in adding them)... What about extensions, functions (static procedures should not be called a method, methods operate on an instance not a class), enum, collections (more specific than lists), and exceptions? Also if you want multi-player; authentication protocols, multi-threading, data modeling, and database experiences.

    Why do you want Windows Forms experience?

    While BitConverter is nice, it doesn't test bits. Here is a class that will help you (and me) facilitate bit testing...

    [code]public static class Bit
    {
    public static uint And(string number1, string number2)
    {
    return (ToNumber(number1) & ToNumber(number2));
    }

    public static uint And(uint number1, uint number2)
    {
    return (number1 & number2);
    }

    public static uint Or(string number1, string number2)
    {
    return (ToNumber(number1) | ToNumber(number2));
    }

    public static uint Or(uint number1, uint number2)
    {
    return (number1 | number2);
    }

    public static uint XOr(string number1, string number2)
    {
    return (ToNumber(number1) ^ ToNumber(number2));
    }

    public static uint XOr(uint number1, uint number2)
    {
    return (number1 ^ number2);
    }

    public static uint Not(string number)
    {
    return (~ToNumber(number));
    }

    public static uint Not(uint number)
    {
    return (~number);
    }

    public static uint LeftShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) << numberOfDigits);
    }

    public static uint LeftShift(uint number, int numberOfDigits)
    {
    return (number << numberOfDigits);
    }

    public static uint RightShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) >> numberOfDigits);
    }

    public static uint RightShift(uint number, int numberOfDigits)
    {
    return (number >> numberOfDigits);
    }

    public static bool TestBit(string number, int bitPosition)
    {
    return ((ToNumber(number) & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static bool TestBit(uint number, int bitPosition)
    {
    return ((number & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static uint ClearBitmask(string number, string mask)
    {
    return ClearBit(ToNumber(number), ToNumber(mask));
    }

    public static uint ClearBitmask(uint number, uint mask)
    {
    return ClearBit(number, mask);
    }

    public static uint SetBitmask(string number, string mask)
    {
    return SetBit(ToNumber(number), ToNumber(mask));
    }

    public static uint SetBitmask(uint number, uint mask)
    {
    return SetBit(number, mask);
    }

    public static byte SetBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static byte ClearBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint SetBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint ClearBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static string ToBinary(string number)
    {
    return ToBinary(ToNumber(number));
    }

    public static string ToBinary(uint number)
    {
    try
    {
    return Convert.ToString(number, 2);
    }
    catch
    {
    return "0";
    }
    }

    public static uint ToValue(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString, 2);
    }
    catch
    {
    return 0;
    }
    }

    public static uint ToNumber(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString);
    }
    catch
    {
    return 0;
    }
    }
    }[/code]
  • I am so itching to make an XNA game myself and LOVE math handling classes, but am too busy with my current personal project, and work.

    You seem lite on requirements, unless you have these skill yourself (I'm bragging a bit in adding them)... What about extensions, functions (static procedures should not be called a method, methods operate on an instance not a class), enum, collections (more specific than lists), and exceptions? Also if you want multi-player; authentication protocols, multi-threading, data modeling, and database experiences.

    Why do you want Windows Forms experience?

    While BitConverter is nice, it doesn't test bits. Here is a class that will help you (and me) facilitate bit testing. And also my MathHelper class.

    [code]public static class Bit
    {
    public static uint And(string number1, string number2)
    {
    return (ToNumber(number1) & ToNumber(number2));
    }

    public static uint And(uint number1, uint number2)
    {
    return (number1 & number2);
    }

    public static uint Or(string number1, string number2)
    {
    return (ToNumber(number1) | ToNumber(number2));
    }

    public static uint Or(uint number1, uint number2)
    {
    return (number1 | number2);
    }

    public static uint XOr(string number1, string number2)
    {
    return (ToNumber(number1) ^ ToNumber(number2));
    }

    public static uint XOr(uint number1, uint number2)
    {
    return (number1 ^ number2);
    }

    public static uint Not(string number)
    {
    return (~ToNumber(number));
    }

    public static uint Not(uint number)
    {
    return (~number);
    }

    public static uint LeftShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) << numberOfDigits);
    }

    public static uint LeftShift(uint number, int numberOfDigits)
    {
    return (number << numberOfDigits);
    }

    public static uint RightShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) >> numberOfDigits);
    }

    public static uint RightShift(uint number, int numberOfDigits)
    {
    return (number >> numberOfDigits);
    }

    public static bool TestBit(string number, int bitPosition)
    {
    return ((ToNumber(number) & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static bool TestBit(uint number, int bitPosition)
    {
    return ((number & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static uint ClearBitmask(string number, string mask)
    {
    return ClearBit(ToNumber(number), ToNumber(mask));
    }

    public static uint ClearBitmask(uint number, uint mask)
    {
    return ClearBit(number, mask);
    }

    public static uint SetBitmask(string number, string mask)
    {
    return SetBit(ToNumber(number), ToNumber(mask));
    }

    public static uint SetBitmask(uint number, uint mask)
    {
    return SetBit(number, mask);
    }

    public static byte SetBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static byte ClearBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint SetBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint ClearBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static string ToBinary(string number)
    {
    return ToBinary(ToNumber(number));
    }

    public static string ToBinary(uint number)
    {
    try
    {
    return Convert.ToString(number, 2);
    }
    catch
    {
    return "0";
    }
    }

    public static uint ToValue(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString, 2);
    }
    catch
    {
    return 0;
    }
    }

    public static uint ToNumber(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString);
    }
    catch
    {
    return 0;
    }
    }
    }

    public static class MathHelper
    {
    public static double Clamp(this double value, double min, double max)
    {
    if (value < min)
    value = min;
    if (value > max)
    value = max;
    return value;
    }

    public static int Clamp(this int value, int min, int max)
    {
    if (value < min)
    value = min;
    if (value > max)
    value = max;
    return value;
    }

    public static short Clamp(this short value, short min, short max)
    {
    if (value < min)
    value = min;
    if (value > max)
    value = max;
    return value;
    }

    public static double ToStandardAngle(double angle)
    {
    while (angle < 0)
    angle += 360;
    while (angle >= 360)
    angle -= 360;
    return angle;
    }

    public static double DegreesToRadians(double degrees)
    {
    return degrees * Math.PI / 180;
    }

    public static double RadiansToDegrees(double radians)
    {
    return ToStandardAngle(radians * 180 / Math.PI);
    }

    public static Point FindPointOnCircle(Point center, double diameter, double angleDegrees)
    {
    angleDegrees = ToStandardAngle(angleDegrees);
    double angleRadians = DegreesToRadians(angleDegrees);
    double x = center.X + (diameter * Math.Cos(angleRadians));
    double y = center.Y + (diameter * Math.Sin(angleRadians));
    return new Point(x, y);
    }

    public static double FindAngleToPoint(Point from, Point to)
    {
    return Math.Atan2(to.Y - from.Y, to.X - from.X);
    }

    public static double FindDistanceBetweenPoints(Point from, Point to)
    {
    return Math.Sqrt(
    Math.Pow((to.X - from.X), 2) +
    Math.Pow((to.Y - from.Y), 2));
    }

    }
    [/code]
  • I am so itching to make an XNA game myself and LOVE math handling classes, but am too busy with my current personal project, and work.

    You seem lite on requirements, unless you have these skill yourself (I'm bragging a bit in adding them)... What about extensions, functions (static procedures should not be called a method, methods operate on an instance not a class), enum, collections (more specific than lists), and exceptions? Also if you want multi-player; authentication protocols, multi-threading, data modeling, and database experiences.

    Why do you want Windows Forms experience?

    While BitConverter is nice, it doesn't test bits. Here is a class that will help you (and me) facilitate bit testing. And also my MathHelper class.

    [code]public static class Bit
    {
    public static uint And(string number1, string number2)
    {
    return (ToNumber(number1) & ToNumber(number2));
    }

    public static uint And(uint number1, uint number2)
    {
    return (number1 & number2);
    }

    public static uint Or(string number1, string number2)
    {
    return (ToNumber(number1) | ToNumber(number2));
    }

    public static uint Or(uint number1, uint number2)
    {
    return (number1 | number2);
    }

    public static uint XOr(string number1, string number2)
    {
    return (ToNumber(number1) ^ ToNumber(number2));
    }

    public static uint XOr(uint number1, uint number2)
    {
    return (number1 ^ number2);
    }

    public static uint Not(string number)
    {
    return (~ToNumber(number));
    }

    public static uint Not(uint number)
    {
    return (~number);
    }

    public static uint LeftShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) << numberOfDigits);
    }

    public static uint LeftShift(uint number, int numberOfDigits)
    {
    return (number << numberOfDigits);
    }

    public static uint RightShift(string number, int numberOfDigits)
    {
    return (ToNumber(number) >> numberOfDigits);
    }

    public static uint RightShift(uint number, int numberOfDigits)
    {
    return (number >> numberOfDigits);
    }

    public static bool TestBit(string number, int bitPosition)
    {
    return ((ToNumber(number) & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static bool TestBit(uint number, int bitPosition)
    {
    return ((number & (uint)Math.Pow(2, bitPosition)) != 0);
    }

    public static uint ClearBitmask(string number, string mask)
    {
    return ClearBit(ToNumber(number), ToNumber(mask));
    }

    public static uint ClearBitmask(uint number, uint mask)
    {
    return ClearBit(number, mask);
    }

    public static uint SetBitmask(string number, string mask)
    {
    return SetBit(ToNumber(number), ToNumber(mask));
    }

    public static uint SetBitmask(uint number, uint mask)
    {
    return SetBit(number, mask);
    }

    public static byte SetBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static byte ClearBit(byte mask, byte srcValue)
    {
    srcValue ^= (byte)(((byte)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint SetBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(-1 ^ srcValue)) & mask);
    return srcValue;
    }

    public static uint ClearBit(uint mask, uint srcValue)
    {
    srcValue ^= (((uint)(0 ^ srcValue)) & mask);
    return srcValue;
    }

    public static string ToBinary(string number)
    {
    return ToBinary(ToNumber(number));
    }

    public static string ToBinary(uint number)
    {
    try
    {
    return Convert.ToString(number, 2);
    }
    catch
    {
    return "0";
    }
    }

    public static uint ToValue(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString, 2);
    }
    catch
    {
    return 0;
    }
    }

    public static uint ToNumber(string numberString)
    {
    try
    {
    return Convert.ToUInt32(numberString);
    }
    catch
    {
    return 0;
    }
    }
    }

    public static class MathHelper
    {
    public static double Clamp(this double value, double min, double max)
    {
    if (value < min)
    value = min;
    if (value > max)
    value = max;
    return value;
    }

    public static int Clamp(this int value, int min, int max)
    {
    if (value < min)
    value = min;
    if (value > max)
    value = max;
    return value;
    }

    public static short Clamp(this short value, short min, short max)
    {
    if (value < min)
    value = min;
    if (value > max)
    value = max;
    return value;
    }

    public static double ToStandardAngle(double angle)
    {
    while (angle < 0)
    angle += 360;
    while (angle >= 360)
    angle -= 360;
    return angle;
    }

    public static double DegreesToRadians(double degrees)
    {
    return degrees * Math.PI / 180;
    }

    public static double RadiansToDegrees(double radians)
    {
    return ToStandardAngle(radians * 180 / Math.PI);
    }

    public static Point FindPointOnCircle(Point center, double diameter, double angleDegrees)
    {
    angleDegrees = ToStandardAngle(angleDegrees);
    double angleRadians = DegreesToRadians(angleDegrees);
    double x = center.X + (diameter * Math.Cos(angleRadians));
    double y = center.Y + (diameter * Math.Sin(angleRadians));
    return new Point(x, y);
    }

    public static double FindAngleToPoint(Point from, Point to)
    {
    return Math.Atan2(to.Y - from.Y, to.X - from.X);
    }

    public static double FindDistanceBetweenPoints(Point from, Point to)
    {
    return Math.Sqrt(
    Math.Pow((to.X - from.X), 2) +
    Math.Pow((to.Y - from.Y), 2));
    }

    }
    [/code]
  • *Expired, please delete!*
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories