static public double FindTilt(EPObj.MemorySafe_CartVect normalVector) { double calculatedTilt = -999; //may need to also take into account other factors that, at this stage, seem to not be important //building Direction of Relative North //zone Direction of Relative North //GlobalGeometryRules coordinate system //I may need to know this in the future then rotate the axis vectors I am making below //x-axis [1 0 0] points east, y-axis [0 1 0] points north, z-axis[0 0 1] points up to the sky //alignment with y axis means north pointing, alignment with z-axis means it is pointing up to the sky (like a flat roof) double nX = 0; double nY = 1; double nZ = 0; EPObj.MemorySafe_CartVect northVector = new EPObj.MemorySafe_CartVect(nX, nY, nZ); double uX = 0; double uY = 0; double uZ = 1; EPObj.MemorySafe_CartVect upVector = new EPObj.MemorySafe_CartVect(uX, uY, uZ); //rotate the axis vectors for the future //ensure the vector passed into the function is a unit vector normalVector = EPObj.UnitVector(normalVector); //get tilt: cross product of normal vector and upVector //since parallel and anti parallel vectors will return the same cross product [0,0,0] I need to filter out the antiparalll case if (normalVector.X == upVector.X * -1 && normalVector.Y == upVector.Y * -1 && normalVector.Z == upVector.Z * -1) { calculatedTilt = 180; return(calculatedTilt); } else { EPObj.MemorySafe_CartVect tiltVector = EPObj.CrossProduct(normalVector, upVector); double tiltVectorMagnitude = EPObj.VectorMagnitude(tiltVector); calculatedTilt = Math.Round(Math.Asin(tiltVectorMagnitude) * 180 / Math.PI, 2); return(calculatedTilt); } }
static public double FindAzimuth(EPObj.MemorySafe_CartVect normalVector) { double calculatedAzimuth = -999; //may need to also take into account other factors that, at this stage, seem to not be important //building Direction of Relative North //zone Direction of Relative North //GlobalGeometryRules coordinate system //I may need to know this in the future then rotate the axis vectors I am making below //x-axis [1 0 0] points east, y-axis [0 1 0] points north, z-axis[0 0 1] points up to the sky //alignment with y axis means north pointing, alignment with z-axis means it is pointing up to the sky (like a flat roof) EPObj.MemorySafe_CartVect northVector = new EPObj.MemorySafe_CartVect(0, 1, 0); EPObj.MemorySafe_CartVect southVector = new EPObj.MemorySafe_CartVect(0, -1, 0); EPObj.MemorySafe_CartVect eastVector = new EPObj.MemorySafe_CartVect(1, 0, 0); EPObj.MemorySafe_CartVect westVector = new EPObj.MemorySafe_CartVect(-1, 0, 0); EPObj.MemorySafe_CartVect upVector = new EPObj.MemorySafe_CartVect(0, 0, 1); //rotate the axis vectors for the future //ensure the vector passed into the function is a unit vector normalVector = EPObj.UnitVector(normalVector); //get X-Y projection of the normal vector //normalVector.Z = 0; //get azimuth: cross product of normal vector x-y projection and northVector //1st quadrant if ((normalVector.X == 0 && normalVector.Y == 1) || (normalVector.X == 1 && normalVector.Y == 0) || (normalVector.X > 0 && normalVector.Y > 0)) { //get azimuth: cross product of normal vector x-y projection and northVector EPObj.MemorySafe_CartVect azVector = EPObj.CrossProduct(normalVector, northVector); double azVectorMagnitude = EPObj.VectorMagnitude(azVector); //modification for when the vector is in different quadrants calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2); return(calculatedAzimuth); } //second quadrant else if (normalVector.X < 0 && normalVector.Y > 0) { EPObj.MemorySafe_CartVect azVector = EPObj.CrossProduct(normalVector, westVector); double azVectorMagnitude = EPObj.VectorMagnitude(azVector); //modification for when the vector is in different quadrants calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2) + 270; return(calculatedAzimuth); } //quadrant 3 else if ((normalVector.X < 0 && normalVector.Y < 0) || (normalVector.X == -1 && normalVector.Y == 0)) { EPObj.MemorySafe_CartVect azVector = EPObj.CrossProduct(normalVector, southVector); double azVectorMagnitude = EPObj.VectorMagnitude(azVector); //modification for when the vector is in different quadrants calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2) + 180; return(calculatedAzimuth); } //quadrant 4 else if ((normalVector.X > 0 && normalVector.Y < 0) || (normalVector.X == 0 && normalVector.Y == -1)) { EPObj.MemorySafe_CartVect azVector = EPObj.CrossProduct(normalVector, eastVector); double azVectorMagnitude = EPObj.VectorMagnitude(azVector); //modification for when the vector is in different quadrants calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2) + 90; return(calculatedAzimuth); } //this will happen to vectors that point straight down or straight up because we are only interested in the X-Y projection and set the Z to zero anyways else if (normalVector.X == 0 && normalVector.Y == 0) { calculatedAzimuth = 0; return(calculatedAzimuth); } //get the return(calculatedAzimuth); }