Example #1
0
 private static string WriteComponent( Golden val )
 {
     string result = "(" + val.B.A + "/" + val.B.B + "," + val.A.A + "/" + val.A.B + ")";
     return result;
 }
Example #2
0
 public void ReadVector( string line )
 {
     //string[] components = line.Split( '\t' );
     string[] components = line.Split( new char[] { '\t', ' ' }, System.StringSplitOptions.RemoveEmptyEntries );
     U = ReadComponent( components[0] );
     X = ReadComponent( components[1] );
     Y = ReadComponent( components[2] );
     Z = ReadComponent( components[3] );
 }
Example #3
0
 private static Golden ReadComponent( string component )
 {
     component = component.Trim( '(', ')' );
     string[] split = component.Split( ',' );
     Fraction b = new Fraction( int.Parse( split[0] ) );
     Fraction a = new Fraction( int.Parse( split[1] ) );
     Golden result = new Golden( a, b );
     return result;
     //Golden scale = new Golden( new Fraction( 5 ), new Fraction( -3 ) );
     //Golden scale = new Golden( new Fraction( 1 ), new Fraction( 0 ) );
     //return result * scale;
 }
Example #4
0
        public bool ProjectPerspective()
        {
            Golden distance = new Golden( new Fraction( -4 ), new Fraction( 4 ) );
            Golden denominator = distance - U;

            double magSquared =
                X.GetAsDouble() * X.GetAsDouble() +
                Y.GetAsDouble() * Y.GetAsDouble() +
                Z.GetAsDouble() * Z.GetAsDouble() +
                U.GetAsDouble() * U.GetAsDouble();

            // The projection.
            Golden scale = new Golden( new Fraction( 1 ), new Fraction( 0 ) );
            Golden factor = (scale * distance) / denominator;

            // Fake projecting to infinity.
            if( denominator.IsZero() || denominator.GetAsDouble() < 0 )
                factor = new Golden( new Fraction( 1000 ), new Fraction( 0 ) );

            X *= factor;
            Y *= factor;
            Z *= factor;
            U = new Golden( new Fraction( 0 ), new Fraction( 0 ) );
            return true;
        }
Example #5
0
 public bool ProjectOrthographic()
 {
     U = new Golden( new Fraction( 0 ), new Fraction( 0 ) );
     return true;
 }
Example #6
0
 /// <summary>
 /// This is here because parameterless constructor leads to 0/0 Fractions.
 /// I should find a better way to deal with this (maybe these all just need to be classes).
 /// </summary>
 public static GoldenVector4D Origin()
 {
     Golden g = new Golden( new Fraction( 0 ), new Fraction( 0 ) );
     return new GoldenVector4D( g, g, g, g );
 }
Example #7
0
 public GoldenVector4D( Golden x, Golden y, Golden z, Golden u )
     : this()
 {
     X = x;
     Y = y;
     Z = z;
     U = u;
 }
Example #8
0
 private static Fraction Denom( Golden g )
 {
     return g.A*g.A + g.A*g.B - g.B*g.B;
 }