1 18 package org.apache.batik.ext.awt.image; 19 20 import java.awt.Color ; 21 22 29 public class DistantLight extends AbstractLight { 30 34 private double azimuth; 35 36 40 private double elevation; 41 42 45 private double Lx, Ly, Lz; 46 47 50 public double getAzimuth(){ 51 return azimuth; 52 } 53 54 57 public double getElevation(){ 58 return elevation; 59 } 60 61 public DistantLight(double azimuth, double elevation, Color color){ 62 super(color); 63 64 this.azimuth = azimuth; 65 this.elevation = elevation; 66 67 Lx = Math.cos(Math.PI*azimuth/180.)*Math.cos(Math.PI*elevation/180.); 68 Ly = Math.sin(Math.PI*azimuth/180.)*Math.cos(Math.PI*elevation/180.); 69 Lz = Math.sin(Math.PI*elevation/180); 70 } 71 72 75 public boolean isConstant(){ 76 return true; 77 } 78 79 86 public void getLight(final double x, final double y, final double z, 87 final double L[]){ 88 L[0] = Lx; 89 L[1] = Ly; 90 L[2] = Lz; 91 } 92 93 109 public double[][] getLightRow(double x, double y, 110 final double dx, final int width, 111 final double[][] z, 112 final double[][] lightRow) { 113 double [][] ret = lightRow; 114 115 if (ret == null) { 116 ret = new double[width][]; 119 120 double[] CL = new double[3]; 121 CL[0]=Lx; 122 CL[1]=Ly; 123 CL[2]=Lz; 124 125 for(int i=0; i<width; i++){ 126 ret[i] = CL; 127 } 128 } else { 129 final double lx = Lx; 130 final double ly = Ly; 131 final double lz = Lz; 132 133 for(int i=0; i<width; i++){ 134 ret[i][0] = lx; 135 ret[i][1] = ly; 136 ret[i][2] = lz; 137 } 138 } 139 140 return ret; 141 } 142 } 143 144 | Popular Tags |