Hi,
Not sure if I am putting this in the right forum. But here goes. I am trying to make a method to check whether or not an object is inside a conic area in 3D world. The catch is the major and minor angle of the cone's tip is different. So the base is not circular but elliptical. So far I have only managed to make a method that has the same major & minor angle (circular base). But what I really need is the one with elliptical base. This is my current method:
I've got an empty declaration of a method like this:Code:bool Sensor::checkInsideCone(const CTransform& sensorXform, const CTransform& objXform, float angle) const { CPos3D sensorTrans = sensorXform.getTranslation(); CPos3D objTrans = objXform.getTranslation(); CVector3f sensorToObjectVec (objTrans - sensorTrans); if ( sensorToObjectVec.getLength() <= getRadius() ) { CVector3f forwardVec; CMatrixf sensorRot; sensorRot = sensorXform.getRotationMatrix(); forwardVec = sensorRot.getRow(1); forwardVec.normalize(); sensorToObjectVec.normalize(); //Get angle between sensor-object and forward vector; float objAngle = acosf(forwardVec * sensorToObjectVec); //arc cos of dot product return (objAngle <= angle); } return false; }
But for the body of that method, I'm blank. Can anybody help me please? Thanks in advance.Code:bool Sensor::checkInsideCone(const CTransform& sensorXform, const CTransform& objXform, float angleHorizontal, float angleVertical) const



4Likes
LinkBack URL
About LinkBacks




