예제 #1
0
파일: Cone.cs 프로젝트: FrankyBoy/JRayX
 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;
 }
예제 #2
0
파일: Sky.cs 프로젝트: FrankyBoy/JRayX
        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));
        }
예제 #3
0
파일: Cone.cs 프로젝트: FrankyBoy/JRayX
        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));
        }
예제 #4
0
        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);
        }