public override RtColor PatternAt(RtPoint point) { var distance = ColorB - ColorA; var fraction = point.X - Math.Floor(point.X); return(ColorA + distance * fraction); }
public bool Equals(RtPoint other) { return(other.X.ApproximateEquals(X) && other.Y.ApproximateEquals(Y) && other.Z.ApproximateEquals(Z) && other.W.ApproximateEquals(W)); }
public RtVector NormalAt(RtPoint worldPoint, Intersection hit) { var localPoint = WorldToShape(worldPoint); var localNormal = LocalNormalAt(localPoint, hit); var worldNormal = NormalToWorld(localNormal); return(worldNormal); }
public RtPoint Perturb(RtPoint localPoint) { var noise = new OpenSimplexNoise(); var newX = localPoint.X + noise.Evaluate(localPoint.X, localPoint.Y, localPoint.Z) * _factor; var newY = localPoint.Y + noise.Evaluate(localPoint.X, localPoint.Y, localPoint.Z + 1) * _factor; var newZ = localPoint.Z + noise.Evaluate(localPoint.X, localPoint.Y, localPoint.Z + 2) * _factor; return(new RtPoint(newX, newY, newZ)); }
public Triangle(RtPoint point1, RtPoint point2, RtPoint point3, RtVector normal1, RtVector normal2, RtVector normal3) { Point1 = point1; Point2 = point2; Point3 = point3; Normal1 = normal1; Normal2 = normal2; Normal3 = normal3; }
public RtPoint WorldToShape(RtPoint worldPoint) { if (Parent != null) { worldPoint = Parent.WorldToShape(worldPoint); } return(Transform.Inverse() * worldPoint); }
public override RtColor PatternAt(RtPoint point) { if (Math.Floor(point.X) % 2 == 0) { return(ColorA); } return(ColorB); }
public override RtColor PatternAt(RtPoint point) { if (Math.Floor(Math.Sqrt(Math.Pow(point.X, 2.0) + Math.Pow(point.Z, 2.0))) % 2 == 0) { return(ColorA); } return(ColorB); }
public override RtVector LocalNormalAt(RtPoint point, Intersection hit) { if (hit == null) { return(Normal); } else { return(Normal2 * hit.U + Normal3 * hit.V + Normal1 * (1 - hit.U - hit.V)); } }
public override double IntensityAt(RtPoint point, World world) { if (world.IsShadowed(Position, point)) { return(0.0); } else { return(1.0); } }
public RtColor PatternAtShape(Shape shape, RtPoint worldPoint) { var shapePoint = shape.Transform.Inverse() * worldPoint; var patterPoint = Transform.Inverse() * shapePoint; if (IsPerturbed && PerturbBy != null) { patterPoint = PerturbBy.Perturb(patterPoint); } return(PatternAt(patterPoint)); }
public AreaLight(RtPoint corner, RtVector uVector, int uSteps, RtVector vVector, int vSteps, RtColor intensity) { Corner = corner; UVector = uVector / uSteps; USteps = uSteps; VVector = vVector / vSteps; VSteps = vSteps; Intensity = intensity; var middle = (uVector / 2) + (vVector / 2); Position = new RtPoint(middle.X, middle.Y, middle.Z); Samples = uSteps * vSteps; }
public override RtVector LocalNormalAt(RtPoint point, Intersection hit) { var maxC = (new double[] { Math.Abs(point.X), Math.Abs(point.Y), Math.Abs(point.Z) }).Max(); if (maxC == Math.Abs(point.X)) { return(new RtVector(point.X, 0, 0)); } else if (maxC == Math.Abs(point.Y)) { return(new RtVector(0, point.Y, 0)); } return(new RtVector(0, 0, point.Z)); }
public override RtVector LocalNormalAt(RtPoint point, Intersection hit) { var distance = Math.Pow(point.X, 2) + Math.Pow(point.Z, 2); if (distance < 1 && point.Y >= Maximum - DoubleExtensions.EPSILON) { return(new RtVector(0, 1, 0)); } else if (distance < 1 && point.Y <= Minimum + DoubleExtensions.EPSILON) { return(new RtVector(0, -1, 0)); } else { return(new RtVector(point.X, 0, point.Z)); } }
public override double IntensityAt(RtPoint point, World world) { var total = 0.0; for (int v = 0; v < VSteps; v++) { for (int u = 0; u < USteps; u++) { var lightPosition = PointOnLight(u, v); if (!world.IsShadowed(lightPosition, point)) { total += 1.0; } } } var results = total / Samples; return(results); }
public bool IsShadowed(RtPoint lightPosition, RtPoint point) { var vector = lightPosition - point; var distance = vector.Magnitude(); var direction = vector.Normalize(); var ray = new Ray(point, direction); var intersetions = Intersect(ray); var hit = intersetions.ShadowHit(); if (hit != null && hit.Time < distance) { return(true); } else { return(false); } }
public override RtColor PatternAt(RtPoint point) { if (Math.Floor(Math.Sqrt(Math.Pow(point.X, 2.0) + Math.Pow(point.Z, 2.0))) % 2 == 0) { var distance = ColorA2 - ColorA1; var distance1 = (ColorA2 - ColorA1) / 2; var t = Math.Atan2(point.Z, point.X); var fraction = Math.Abs(t) / Math.PI * 2; if (t >= 0) { return(ColorA2 - distance * fraction); } else { return(ColorA2 + distance * fraction); } } return(ColorB); }
public PointLight(RtPoint position, RtColor color) { Position = position; Intensity = color; Samples = 1; }
public void AddVertex(RtPoint rtPoint) { _vertices.Add(rtPoint); }
public abstract RtVector LocalNormalAt(RtPoint point, Intersection hit);
public override RtVector LocalNormalAt(RtPoint point, Intersection hit) { throw new System.NotImplementedException(); }
public abstract RtColor PatternAt(RtPoint point);
public Transform Translation(RtPoint location) { return(Translation(location.X, location.Y, location.Z)); }
public Triangle(RtPoint point1, RtPoint point2, RtPoint point3) { Point1 = point1; Point2 = point2; Point3 = point3; }
public double Perlin(RtPoint point) { return(Perlin(point.X, point.Y, point.Z)); }
public abstract double IntensityAt(RtPoint point, World world);
public override RtVector LocalNormalAt(RtPoint point, Intersection hit) { return(new RtVector(0, 1, 0)); }
public override RtVector LocalNormalAt(RtPoint shapePoint, Intersection hit) { return(shapePoint.DistanceFromZero()); }
public Ray(RtPoint origin, RtVector direction) { Origin = origin; Direction = direction; }