public double4x2(double4 c0, double4 c1) { this.c0 = c0; this.c1 = c1; }
public double4x3(uint v) { this.c0 = v; this.c1 = v; this.c2 = v; }
public double4x2(float4x2 v) { this.c0 = v.c0; this.c1 = v.c1; }
public static double4x4 double4x4(double4 c0, double4 c1, double4 c2, double4 c3) { return(new double4x4(c0, c1, c2, c3)); }
internal static real CubicLerp(real4 v, real t) { return(CubicLerp(v.x, v.y, v.z, v.w, t)); }
public double4x2(bool4x2 v) { this.c0 = math.select(new double4(0.0), new double4(1.0), v.c0); this.c1 = math.select(new double4(0.0), new double4(1.0), v.c1); }
public double4x2(uint4x2 v) { this.c0 = v.c0; this.c1 = v.c1; }
public double4x3(float v) { this.c0 = v; this.c1 = v; this.c2 = v; }
public double4x3(double4 c0, double4 c1, double4 c2) { this.c0 = c0; this.c1 = c1; this.c2 = c2; }
public double4 NextDouble4(double4 max) { return(NextDouble4() * max); }
public double4 NextDouble4(double4 min, double4 max) { return(NextDouble4() * (max - min) + min); }
public static double4 sqr(double4 x) { return(new double4(sqr(x.x), sqr(x.y), sqr(x.z), sqr(x.w))); }
public quaternion_d(double4 value) { this.value = value; }
public real GetValue(int seed, real3 p) { int3 p1 = FastFloor(p); real3 s = p - p1; p1 *= Prime; int3 p0 = p1 - Prime; int3 p2 = p1 + Prime; int3 p3 = p1 + unchecked (Prime * 2); var s1 = new real4 { x = ValCoord(seed, p0), y = ValCoord(seed, p0.x, p1.y, p0.z), z = ValCoord(seed, p0.x, p2.y, p0.z), w = ValCoord(seed, p0.x, p3.y, p0.z) }; var s2 = new real4 { x = ValCoord(seed, p1.x, p0.y, p0.z), y = ValCoord(seed, p1.x, p1.y, p0.z), z = ValCoord(seed, p1.x, p2.y, p0.z), w = ValCoord(seed, p1.x, p3.y, p0.z) }; var s3 = new real4 { x = ValCoord(seed, p2.x, p0.y, p0.z), y = ValCoord(seed, p2.x, p1.y, p0.z), z = ValCoord(seed, p2.x, p2.y, p0.z), w = ValCoord(seed, p2.x, p3.y, p0.z) }; var s4 = new real4 { x = ValCoord(seed, p3.x, p0.y, p0.z), y = ValCoord(seed, p3.x, p1.y, p0.z), z = ValCoord(seed, p3.x, p2.y, p0.z), w = ValCoord(seed, p3.x, p3.y, p0.z) }; var t1 = new real4 { x = ValCoord(seed, p0.x, p0.y, p1.z), y = ValCoord(seed, p0.x, p1.y, p1.z), z = ValCoord(seed, p0.x, p2.y, p1.z), w = ValCoord(seed, p0.x, p3.y, p1.z) }; var t2 = new real4 { x = ValCoord(seed, p1.x, p0.y, p1.z), y = ValCoord(seed, p1.x, p1.y, p1.z), z = ValCoord(seed, p1.x, p2.y, p1.z), w = ValCoord(seed, p1.x, p3.y, p1.z) }; var t3 = new real4 { x = ValCoord(seed, p2.x, p0.y, p1.z), y = ValCoord(seed, p2.x, p1.y, p1.z), z = ValCoord(seed, p2.x, p2.y, p1.z), w = ValCoord(seed, p2.x, p3.y, p1.z) }; var t4 = new real4 { x = ValCoord(seed, p3.x, p0.y, p1.z), y = ValCoord(seed, p3.x, p1.y, p1.z), z = ValCoord(seed, p3.x, p2.y, p1.z), w = ValCoord(seed, p3.x, p3.y, p1.z) }; var u1 = new real4 { x = ValCoord(seed, p0.x, p0.y, p2.z), y = ValCoord(seed, p0.x, p1.y, p2.z), z = ValCoord(seed, p0.x, p2.y, p2.z), w = ValCoord(seed, p0.x, p3.y, p2.z) }; var u2 = new real4 { x = ValCoord(seed, p1.x, p0.y, p2.z), y = ValCoord(seed, p1.x, p1.y, p2.z), z = ValCoord(seed, p1.x, p2.y, p2.z), w = ValCoord(seed, p1.x, p3.y, p2.z), }; var u3 = new real4 { x = ValCoord(seed, p2.x, p0.y, p2.z), y = ValCoord(seed, p2.x, p1.y, p2.z), z = ValCoord(seed, p2.x, p2.y, p2.z), w = ValCoord(seed, p2.x, p3.y, p2.z) }; var u4 = new real4 { x = ValCoord(seed, p3.x, p0.y, p2.z), y = ValCoord(seed, p3.x, p1.y, p2.z), z = ValCoord(seed, p3.x, p2.y, p2.z), w = ValCoord(seed, p3.x, p3.y, p2.z) }; var v1 = new real4 { x = ValCoord(seed, p0.x, p0.y, p3.z), y = ValCoord(seed, p0.x, p1.y, p3.z), z = ValCoord(seed, p0.x, p2.y, p3.z), w = ValCoord(seed, p0.x, p3.y, p3.z) }; var v2 = new real4 { x = ValCoord(seed, p1.x, p0.y, p3.z), y = ValCoord(seed, p1.x, p1.y, p3.z), z = ValCoord(seed, p1.x, p2.y, p3.z), w = ValCoord(seed, p1.x, p3.y, p3.z) }; var v3 = new real4 { x = ValCoord(seed, p2.x, p0.y, p3.z), y = ValCoord(seed, p2.x, p1.y, p3.z), z = ValCoord(seed, p2.x, p2.y, p3.z), w = ValCoord(seed, p2.x, p3.y, p3.z) }; var v4 = new real4 { x = ValCoord(seed, p3.x, p0.y, p3.z), y = ValCoord(seed, p3.x, p1.y, p3.z), z = ValCoord(seed, p3.x, p2.y, p3.z), w = ValCoord(seed, p3.x, p3.y, p3.z) }; var sl = CubicLerp(s1, s2, s3, s4, s.x); var tl = CubicLerp(t1, t2, t3, t4, s.x); var ul = CubicLerp(u1, u2, u3, u4, s.x); var vl = CubicLerp(v1, v2, v3, v4, s.x); var sf = new real4(sl.x, tl.x, ul.x, vl.x); var tf = new real4(sl.y, tl.y, ul.y, vl.y); var uf = new real4(sl.z, tl.z, ul.z, vl.z); var vf = new real4(sl.z, tl.z, ul.z, vl.z); return(CubicLerp(CubicLerp(sf, tf, uf, vf, s.y), s.z) * (1 / (1.5f * 1.5f * 1.5f))); }
public double4x2(double v) { this.c0 = v; this.c1 = v; }
public double4x3(double v) { this.c0 = v; this.c1 = v; this.c2 = v; }
public static double4x2 double4x2(double4 c0, double4 c1) { return(new double4x2(c0, c1)); }
public static double4x3 double4x3(double4 c0, double4 c1, double4 c2) { return(new double4x3(c0, c1, c2)); }
public double4x2(uint v) { this.c0 = v; this.c1 = v; }
public double4x3(bool v) { this.c0 = math.select(new double4(0.0), new double4(1.0), v); this.c1 = math.select(new double4(0.0), new double4(1.0), v); this.c2 = math.select(new double4(0.0), new double4(1.0), v); }
public double4x2(float v) { this.c0 = v; this.c1 = v; }
public double4x3(int4x3 v) { this.c0 = v.c0; this.c1 = v.c1; this.c2 = v.c2; }
/// <summary>Returns the double4x4 full inverse of a double4x4 matrix.</summary> public static double4x4 inverse(double4x4 m) { double4 c0 = m.c0; double4 c1 = m.c1; double4 c2 = m.c2; double4 c3 = m.c3; double4 r0y_r1y_r0x_r1x = movelh(c1, c0); double4 r0z_r1z_r0w_r1w = movelh(c2, c3); double4 r2y_r3y_r2x_r3x = movehl(c0, c1); double4 r2z_r3z_r2w_r3w = movehl(c3, c2); double4 r1y_r2y_r1x_r2x = shuffle(c1, c0, ShuffleComponent.LeftY, ShuffleComponent.LeftZ, ShuffleComponent.RightY, ShuffleComponent.RightZ); double4 r1z_r2z_r1w_r2w = shuffle(c2, c3, ShuffleComponent.LeftY, ShuffleComponent.LeftZ, ShuffleComponent.RightY, ShuffleComponent.RightZ); double4 r3y_r0y_r3x_r0x = shuffle(c1, c0, ShuffleComponent.LeftW, ShuffleComponent.LeftX, ShuffleComponent.RightW, ShuffleComponent.RightX); double4 r3z_r0z_r3w_r0w = shuffle(c2, c3, ShuffleComponent.LeftW, ShuffleComponent.LeftX, ShuffleComponent.RightW, ShuffleComponent.RightX); double4 r0_wzyx = shuffle(r0z_r1z_r0w_r1w, r0y_r1y_r0x_r1x, ShuffleComponent.LeftZ, ShuffleComponent.LeftX, ShuffleComponent.RightX, ShuffleComponent.RightZ); double4 r1_wzyx = shuffle(r0z_r1z_r0w_r1w, r0y_r1y_r0x_r1x, ShuffleComponent.LeftW, ShuffleComponent.LeftY, ShuffleComponent.RightY, ShuffleComponent.RightW); double4 r2_wzyx = shuffle(r2z_r3z_r2w_r3w, r2y_r3y_r2x_r3x, ShuffleComponent.LeftZ, ShuffleComponent.LeftX, ShuffleComponent.RightX, ShuffleComponent.RightZ); double4 r3_wzyx = shuffle(r2z_r3z_r2w_r3w, r2y_r3y_r2x_r3x, ShuffleComponent.LeftW, ShuffleComponent.LeftY, ShuffleComponent.RightY, ShuffleComponent.RightW); double4 r0_xyzw = shuffle(r0y_r1y_r0x_r1x, r0z_r1z_r0w_r1w, ShuffleComponent.LeftZ, ShuffleComponent.LeftX, ShuffleComponent.RightX, ShuffleComponent.RightZ); // Calculate remaining inner term pairs. inner terms have zw=-xy, so we only have to calculate xy and can pack two pairs per vector. double4 inner12_23 = r1y_r2y_r1x_r2x * r2z_r3z_r2w_r3w - r1z_r2z_r1w_r2w * r2y_r3y_r2x_r3x; double4 inner02_13 = r0y_r1y_r0x_r1x * r2z_r3z_r2w_r3w - r0z_r1z_r0w_r1w * r2y_r3y_r2x_r3x; double4 inner30_01 = r3z_r0z_r3w_r0w * r0y_r1y_r0x_r1x - r3y_r0y_r3x_r0x * r0z_r1z_r0w_r1w; // Expand inner terms back to 4 components. zw signs still need to be flipped double4 inner12 = shuffle(inner12_23, inner12_23, ShuffleComponent.LeftX, ShuffleComponent.LeftZ, ShuffleComponent.RightZ, ShuffleComponent.RightX); double4 inner23 = shuffle(inner12_23, inner12_23, ShuffleComponent.LeftY, ShuffleComponent.LeftW, ShuffleComponent.RightW, ShuffleComponent.RightY); double4 inner02 = shuffle(inner02_13, inner02_13, ShuffleComponent.LeftX, ShuffleComponent.LeftZ, ShuffleComponent.RightZ, ShuffleComponent.RightX); double4 inner13 = shuffle(inner02_13, inner02_13, ShuffleComponent.LeftY, ShuffleComponent.LeftW, ShuffleComponent.RightW, ShuffleComponent.RightY); // Calculate minors double4 minors0 = r3_wzyx * inner12 - r2_wzyx * inner13 + r1_wzyx * inner23; double4 denom = r0_xyzw * minors0; // Horizontal sum of denominator. Free sign flip of z and w compensates for missing flip in inner terms. denom = denom + shuffle(denom, denom, ShuffleComponent.LeftY, ShuffleComponent.LeftX, ShuffleComponent.RightW, ShuffleComponent.RightZ); // x+y x+y z+w z+w denom = denom - shuffle(denom, denom, ShuffleComponent.LeftZ, ShuffleComponent.LeftZ, ShuffleComponent.RightX, ShuffleComponent.RightX); // x+y-z-w x+y-z-w z+w-x-y z+w-x-y double4 rcp_denom_ppnn = double4(1.0) / denom; double4x4 res; res.c0 = minors0 * rcp_denom_ppnn; double4 inner30 = shuffle(inner30_01, inner30_01, ShuffleComponent.LeftX, ShuffleComponent.LeftZ, ShuffleComponent.RightZ, ShuffleComponent.RightX); double4 inner01 = shuffle(inner30_01, inner30_01, ShuffleComponent.LeftY, ShuffleComponent.LeftW, ShuffleComponent.RightW, ShuffleComponent.RightY); double4 minors1 = r2_wzyx * inner30 - r0_wzyx * inner23 - r3_wzyx * inner02; res.c1 = minors1 * rcp_denom_ppnn; double4 minors2 = r0_wzyx * inner13 - r1_wzyx * inner30 - r3_wzyx * inner01; res.c2 = minors2 * rcp_denom_ppnn; double4 minors3 = r1_wzyx * inner02 - r0_wzyx * inner12 + r2_wzyx * inner01; res.c3 = minors3 * rcp_denom_ppnn; return(res); }
internal static real4 CubicLerp(real4 a, real4 b, real4 c, real4 d, real4 t) { real4 p = (d - c) - (a - b); return(t * t * t * p + t * t * ((a - b) - p) + t * (c - a) + b); }