public Plane(Vec3 normal, double distance) { Debug.Assert(Num.AlmostEqual(normal.Abs(), 1.0)); this.normal = normal; this.distance = distance; }
public Ray(Vec3 origin, Vec3 dir) { Debug.Assert(Num.AlmostEqual(dir.Abs(), 1.0)); this.origin = origin; this.dir = dir; }
/// <summary> /// Make a random unit vector. /// </summary> /// <remarks> /// Samples points in [-1, -1, -1] - [1, 1, 1] until one that's neither at /// the origin or outside the unit sphere is found. Returns this vector /// normalized to unit length. /// </remarks> public Vec3 UnitVec() { double len; Vec3 result; do { result = new Vec3( RandDouble(-1.0, 1.0), RandDouble(-1.0, 1.0), RandDouble(-1.0, 1.0)); len = result.Abs(); } while (len < Num.Epsilon || len > 1.0); return result.Unit(); }