Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

ImplicitSphere.cpp

00001 
00006 #include "ImplicitSphere.h"
00007 
00008 
00009 ImplicitSphere::ImplicitSphere(MDistance r, float w, MPoint c) 
00010         : ImplicitFunction(w) { 
00011         radius = r;
00012         center = c;
00013         a = radius.value();
00014         b = radius.value();
00015         z = radius.value();
00016         
00017 }
00018 
00019 
00020 float ImplicitSphere::implicitValue(MPoint p) {
00021         //translate the point to the correct position
00022         p *= m.asMatrix().inverse();
00023         
00024         //calculate the implicit function value
00025         //according to the function of an ellipsoid
00026         float result = 1 - (std::pow(((p.x-center.x)/a),2))
00027                                         - (std::pow(((p.y-center.y)/b),2))
00028                                         - (std::pow(((p.z-center.z)/z),2));
00029         
00030         //multiply by the weight to specify the influence of this
00031         //ImplicitSphere
00032         return result * weight;
00033 }
00034                 
00035 void ImplicitSphere::applyMatrix(MTransformationMatrix matrix) {
00036         m = matrix;
00037 }
00038 
00039 void ImplicitSphere::applyRadiusWeight(MDistance r, float w) {
00040         radius = r;
00041         weight = w;
00042         a = radius.value();
00043         b = radius.value();
00044         z = radius.value();
00045 }
00046 
00047 bool ImplicitSphere::testInfluance(MPoint p) {
00048         //test if the point lies with in the influence radius
00049         //by a simple sign test.
00050         if(implicitValue(p)/weight >= 0) {
00051                 return true;
00052         } else {
00053                 return false;
00054         }
00055 }
00056                 

Generated on Mon Jun 13 03:18:00 2005 for ImplicitFunctions by  doxygen 1.4.1