00001 package commandline.Algorithms; 00002 00003 00004 import commandline.ImageStuff.Image; 00005 import commandline.ImageStuff.GeometricObjects.GenericEdge; 00006 import commandline.debuggingCode.Debug; 00007 00008 public class RicoSingleton { 00009 00013 private float euclidischelengte; 00017 private float hoogte; 00021 private float rico_edge; 00025 private float rico_normale; 00026 private static RicoSingleton instance; 00027 00028 private RicoSingleton(GenericEdge e,boolean USE_FUNCTION_VALUE) { 00029 euclidischelengte=0; hoogte=0; rico_edge=0; rico_normale=0; 00030 init(e,USE_FUNCTION_VALUE); 00031 } 00032 00033 private void init(GenericEdge e,boolean USE_FUNCTION_VALUE){ 00034 calculateRicoNormalOn(e,USE_FUNCTION_VALUE); 00035 } 00036 00037 private float calculateRicoNormalOn(GenericEdge e,boolean USE_FUNCTION_VALUE){ 00038 euclidischelengte= e.getEuclidischeLengte(); 00039 if(USE_FUNCTION_VALUE){ 00040 hoogte=Image.getInstance().getPuntOpEnty(e.getEind()).getZ()-Image.getInstance().getPuntOpEnty(e.getBegin()).getZ(); 00041 } 00042 else{ 00043 hoogte=e.getEind().getZ()-e.getBegin().getZ(); 00044 } 00045 rico_edge=hoogte/euclidischelengte; 00046 rico_normale=-euclidischelengte/hoogte; 00047 return rico_normale; 00048 } 00049 00050 public float getRicoEdge(){ 00051 return this.rico_edge; 00052 } 00053 00054 public float getRicoNormale(){ 00055 return this.rico_normale; 00056 } 00057 00058 public static RicoSingleton getInstance(GenericEdge e,boolean USE_FUNCTION_VALUE){ 00059 if(instance!=null){instance.init(e,USE_FUNCTION_VALUE);return instance;} 00060 instance= new RicoSingleton(e,USE_FUNCTION_VALUE); 00061 if(Debug.DEBUG && Debug.DEBUG_RICOSINGLETON) {Debug.print("Creatie van RicoSingleton");} 00062 return instance; 00063 } 00064 }
1.5.5