public ScaleMatrix4(Vec4 v) { base.init(); x = v.X; y = v.Y; z = v.Z; Update(); }
public override void Update() { SetIdentity(); double xDelta = right - left; double yDelta = top - bottom; double zDelta = far - near; Vec4 sVec = new Vec4(2 / xDelta, 2/yDelta, 2/zDelta); Vec4 tVec = new Vec4(-((right + left) / xDelta), -((top + bottom) / yDelta), -((far + near) / zDelta)); Set(new TranslateMatrix4(tVec) * new ScaleMatrix4(sVec)); }
public Vec4(Vec4 original) { Set(original.X, original.Y, original.Z, 1); }
public bool EqualTo3D(Vec4 v) { return ((X == v.X) && (Y == v.Y) && (Z == v.Z)); }
public bool EqualTo2D(Vec4 v) { return ((X == v.X) && (Y == v.Y)); }
public bool EqualTo(Vec4 v) { return ((X == v.X) && (Y == v.Y) && (Z == v.Z) && (W == v.W)); }
public double Dot(Vec4 b) { return b.X * x + b.Y * y + b.Z * z + b.W * w; }
public static Vec4 operator *(Matrix4 m, Vec4 v) { Collection<double> res = new Collection<double>(); Collection<double> vCol = v.GetCollection(); for (int i = 0; i < 4; i++) { Collection<double> mCol = m.GetRow(i); double tmp = 0; for (int j = 0; j < 4; j++) tmp += mCol[j] * vCol[j]; res.Add(tmp); } // Und da der Vektor hier nicht unbedingt homogenisiert ist, holen wir das einfach nach Vec4 tmpVec = new Vec4(res); if (tmpVec.W != 0) tmpVec.Homogenize(); return tmpVec; }