1 18 package org.apache.batik.ext.awt.image; 19 20 import java.awt.Color ; 21 22 28 public class PointLight extends AbstractLight { 29 32 private double lightX, lightY, lightZ; 33 34 37 public double getLightX(){ 38 return lightX; 39 } 40 41 44 public double getLightY(){ 45 return lightY; 46 } 47 48 51 public double getLightZ(){ 52 return lightZ; 53 } 54 55 public PointLight(double lightX, double lightY, double lightZ, 56 Color lightColor){ 57 super(lightColor); 58 this.lightX = lightX; 59 this.lightY = lightY; 60 this.lightZ = lightZ; 61 } 62 63 66 public boolean isConstant(){ 67 return false; 68 } 69 70 78 public final void getLight(final double x, final double y, final double z, 79 final double L[]){ 80 L[0] = lightX - x; 81 L[1] = lightY - y; 82 L[2] = lightZ - z; 83 84 final double norm = Math.sqrt(L[0]*L[0] + 85 L[1]*L[1] + 86 L[2]*L[2]); 87 88 if(norm > 0){ 89 final double invNorm = 1.0/norm; 90 L[0] *= invNorm; 91 L[1] *= invNorm; 92 L[2] *= invNorm; 93 } 94 } 95 } 96 97 | Popular Tags |