public static GaPoTNumFrame CreateGramSchmidtFrame(int vectorsCount, int refVectorIndex, out GaPoTNumFrame kirchhoffFrame) { kirchhoffFrame = CreateKirchhoffFrame(vectorsCount, refVectorIndex); var uPseudoScalar = new GaPoTNumMultivector() .SetTerm( (1 << vectorsCount) - 1, 1.0d ); var cFrame = kirchhoffFrame.GetOrthogonalFrame(true); cFrame.AppendVector( -GaPoTNumUtils .OuterProduct(cFrame) .Gp(uPseudoScalar.CliffordConjugate()) .GetVectorPart() ); Debug.Assert( cFrame.IsOrthonormal() ); Debug.Assert( CreateBasisFrame(vectorsCount).HasSameHandedness(cFrame) ); return(cFrame); }
public GaPoTNumMultivector Sp(GaPoTNumMultivector mv2) { var result = new GaPoTNumMultivector(); foreach (var term1 in _termsDictionary.Values) { if (!mv2._termsDictionary.TryGetValue(term1.IDsPattern, out var term2)) { continue; } var value = term1.Value * term2.Value; if (value == 0) { continue; } if (GaPoTNumUtils.ComputeIsNegativeEGp(term1.IDsPattern, term2.IDsPattern)) { value = -value; } result.AddTerm(new GaPoTNumMultivectorTerm(0, value)); } return(result); }
public GaPoTNumMultivector ApplyRotor(GaPoTNumMultivector rotor) { var r1 = rotor; var r2 = rotor.Reverse(); return(r1.Gp(this).Gp(r2)); }
public GaPoTNumVector ApplyRotor(GaPoTNumMultivector rotor) { var r1 = rotor; var r2 = rotor.Reverse(); var v = ToMultivector(); var mv = r1.Gp(v).Gp(r2); return(mv.GetVectorPart()); }
/// <summary> /// Assuming this multivector is a simple rotor, this extracts its angle and 2-blade of rotation /// </summary> /// <returns></returns> public Tuple <double, GaPoTNumMultivector> GetSimpleRotorAngleBlade() { var scalarPart = GetTermValue(0); var bivectorPart = new GaPoTNumMultivector(GetTermsOfGrade(2)); var halfAngle = Math.Acos(scalarPart); var angle = 2.0d * halfAngle; var blade = bivectorPart / Math.Sin(halfAngle); return(new Tuple <double, GaPoTNumMultivector>(angle, blade)); }
public static GaPoTNumMultivector operator -(GaPoTNumMultivector v) { var result = new GaPoTNumMultivector(); foreach (var term in v._termsDictionary.Values) { result.AddTerm(term.IDsPattern, -term.Value); } return(result); }
/// <summary> /// Create a simple rotor from an angle and a blade /// </summary> /// <param name="rotationAngle"></param> /// <param name="rotationBlade"></param> /// <returns></returns> public static GaPoTNumMultivector CreateSimpleRotor(double rotationAngle, GaPoTNumMultivector rotationBlade) { var cosHalfAngle = Math.Cos(rotationAngle / 2.0d); var sinHalfAngle = Math.Sin(rotationAngle / 2.0d); var rotationBladeScalar = sinHalfAngle / Math.Sqrt(Math.Abs(rotationBlade.Gp(rotationBlade).GetTermValue(0))); var rotor = cosHalfAngle + rotationBladeScalar * rotationBlade; //rotor.IsSimpleRotor(); return(rotor); }
public static GaPoTNumMultivector operator /(GaPoTNumMultivector v, double s) { s = 1.0d / s; var result = new GaPoTNumMultivector(); foreach (var term in v._termsDictionary.Values) { result.AddTerm( term.IDsPattern, term.Value * s ); } return(result); }
public static GaPoTNumMultivector operator +(double v2, GaPoTNumMultivector v1) { var result = new GaPoTNumMultivector(); foreach (var term in v1._termsDictionary.Values) { result.AddTerm( term.IDsPattern, term.Value ); } result.AddTerm(0, v2); return(result); }
public GaPoTNumMultivector Gp(GaPoTNumMultivector mv2) { var result = new GaPoTNumMultivector(); foreach (var term1 in _termsDictionary.Values) { foreach (var term2 in mv2._termsDictionary.Values) { var term = term1.Gp(term2); if (term.Value != 0) { result.AddTerm(term); } } } return(result); }
public static GaPoTNumMultivector operator *(GaPoTNumMultivector v1, GaPoTNumMultivector v2) { var result = new GaPoTNumMultivector(); foreach (var term1 in v1._termsDictionary.Values) { foreach (var term2 in v2._termsDictionary.Values) { var term = term1.Gp(term2); if (term.Value != 0) { result.AddTerm(term); } } } return(result); }
public GaPoTNumMultivector Subtract(GaPoTNumMultivector v) { return(this - v); }
public GaPoTNumMultivector Add(GaPoTNumMultivector v) { return(this + v); }
public GaPoTNumVector GetProjectionOnBlade(GaPoTNumMultivector blade) { return(ToMultivector().Lcp(blade).Lcp(blade.Inverse()).GetVectorPart()); }
public GaPoTNumMultivector GetRotorToVector(GaPoTNumVector v2) { return(GaPoTNumMultivector.CreateSimpleRotor(this, v2)); }
public GaPoTNumMultivector Gp(GaPoTNumMultivector v) { return(ToMultivector().Gp(v)); }