Example #1
0
 // Returns a vector representing the cross product
 // of the current vector and the given one
 public CG_Vector3 CrossProduct(CG_Vector3 vec2)
 {
     return(new CG_Vector3(
                (Y * vec2.Z) - (vec2.Y * Z),
                (Z * vec2.X) - (vec2.Z * X),
                (X * vec2.Y) - (vec2.X * Y)));
 }
Example #2
0
        public override object ConvertFrom(ITypeDescriptorContext context,
                                           CultureInfo culture, object value)
        {
            if (value is string)
            {
                try
                {
                    string s = (string)value;

                    string[] split = s.Split(",".ToCharArray());

                    if (split.Length == 3)
                    {
                        CG_Vector3 Trans = new CG_Vector3(TypesHelper.DoubleParse(split[0]), TypesHelper.DoubleParse(split[1]), TypesHelper.DoubleParse(split[2]));
                        return(Trans);
                    }
                }
                catch
                {
                    throw new ArgumentException(
                              "Can not convert '" + (string)value +
                              "' to type CG_Vector3");
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
Example #3
0
 public CG_Transform(SerializationInfo info, StreamingContext ctxt)
 {
     //Get the values from info and assign them to the appropriate properties
     mPos = (CG_Vector3)info.GetValue("Pos", typeof(CG_Vector3));
     mRot = (CG_Vector3)info.GetValue("Rot", typeof(CG_Vector3));
     mScl = (CG_Vector3)info.GetValue("Scl", typeof(CG_Vector3));
 }
Example #4
0
        public override object ConvertTo(ITypeDescriptorContext context,
                                         CultureInfo culture,
                                         object value,
                                         System.Type destinationType)
        {
            if (destinationType == typeof(System.String) &&
                value is CG_Vector3)
            {
                CG_Vector3 Trans = (CG_Vector3)value;

                return(ToCleanString(Trans.X) + "," + ToCleanString(Trans.Y) + "," + ToCleanString(Trans.Z));
            }
            return(base.ConvertTo(context, culture, value, destinationType));
        }
Example #5
0
 // Returns the dot product of the current vector and
 // the given one
 public double DotProduct(CG_Vector3 vec2)
 {
     return((X * vec2.X) + (Y * vec2.Y) + (Z * vec2.Z));
 }
Example #6
0
 public bool FuzzyEquals(CG_Vector3 vec)
 {
     return(FuzzyEquals(vec, EPSILON));
 }
Example #7
0
 public bool FuzzyEquals(CG_Vector3 vec, double epsilon)
 {
     return(TypesHelper.DoubleIsFuzzyEqual(X, vec.X, epsilon) && TypesHelper.DoubleIsFuzzyEqual(Y, vec.Y, epsilon) && TypesHelper.DoubleIsFuzzyEqual(Z, vec.Z, epsilon));
 }
Example #8
0
 public CG_Transform()
 {
     mPos = new CG_Vector3();
     mRot = new CG_Vector3();
     mScl = new CG_Vector3(1, 1, 1);
 }