public Cone(Vect3 position, Vect3 axis, double phiDegree, Color color) : base(position, axis) { CosPhi = System.Math.Cos(MathHelper.ToRadians(phiDegree)); AxisLength = axis.Length(); LookAt = axis / AxisLength; Color = color; }
public new Color GetColorAt(Vect3 hitPoint) { double hpLength = hitPoint.Length(); double x = System.Math.Acos(hitPoint.Y / hpLength) / System.Math.PI; double y = System.Math.Acos(hitPoint.Z / hpLength) / System.Math.PI; return(_texture.GetColorAt(x, y)); }
public new Sphere GetBoundingSphere() { var @base = Position + LookAt * AxisLength; Vect3 tmp = @base.ProjectOn(LookAt); var normal = (@base - tmp).Normalize(); double len = CosPhi * AxisLength; normal *= len; tmp = @base + normal; @base = @base - normal; var center = (Position + tmp + @base) / 3; tmp = center - Position; return(new Sphere(center, tmp.Length(), Color.Black)); }
public Sphere(Vect3 position, Vect3 lookAt, double rotationRad, Color color) : base(position, lookAt) { Color = color; Radius = lookAt.Length(); // calculate the rotation of the 0-meridian RotVect = lookAt; // check so we don't end up with two linear dependent vectors if (System.Math.Abs(RotVect.Y) > Constants.EPS && System.Math.Abs(RotVect.X) < Constants.EPS && System.Math.Abs(RotVect.Z) < Constants.EPS) { RotVect.X += 1; } else { RotVect.Y += 1; } RotVect = RotVect.CrossProduct(lookAt).Normalize(); LookAt = LookAt.Normalize(); Rotate(lookAt, rotationRad); }