public static MemorySafe_CartVect CreateMemorySafe_Vector(MemorySafe_CartCoord cd1, MemorySafe_CartCoord cd2) { double X = cd2.X - cd1.X; double Y = cd2.Y - cd1.Y; double Z = cd2.Z - cd1.Z; MemorySafe_CartVect vector = new MemorySafe_CartVect(X, Y, Z); return vector; }
public static MemorySafe_CartVect CreateMemorySafe_Vector(MemorySafe_CartCoord cd1, MemorySafe_CartCoord cd2) { double X = cd2.X - cd1.X; double Y = cd2.Y - cd1.Y; double Z = cd2.Z - cd1.Z; MemorySafe_CartVect vector = new MemorySafe_CartVect(X, Y, Z); return(vector); }
public static MemorySafe_Surface convert2MemorySafeSurface(Surface surface) { List<MemorySafe_CartCoord> surfaceCoords = new List<MemorySafe_CartCoord>(); foreach (CartCoord coord in surface.SurfaceCoords) { MemorySafe_CartCoord surfaceCoord = new MemorySafe_CartCoord(coord.X, coord.Y, coord.Z); surfaceCoords.Add(surfaceCoord); } MemorySafe_Surface memSurface = new MemorySafe_Surface(surface.name, surface.multiplier, surface.surfaceType, surface.constructionName, surface.outsideBoundary, surface.zoneName, surface.outsideBoundaryCondition, surface.sunExposureVar, surface.windExposureVar, surface.viewFactor, surface.numVertices, surfaceCoords, surface.tilt, surface.azimuth); return memSurface; }
public static MemorySafe_Surface convert2MemorySafeSurface(Surface surface) { List <MemorySafe_CartCoord> surfaceCoords = new List <MemorySafe_CartCoord>(); foreach (CartCoord coord in surface.SurfaceCoords) { MemorySafe_CartCoord surfaceCoord = new MemorySafe_CartCoord(coord.X, coord.Y, coord.Z); surfaceCoords.Add(surfaceCoord); } MemorySafe_Surface memSurface = new MemorySafe_Surface(surface.name, surface.multiplier, surface.surfaceType, surface.constructionName, surface.outsideBoundary, surface.zoneName, surface.outsideBoundaryCondition, surface.sunExposureVar, surface.windExposureVar, surface.viewFactor, surface.numVertices, surfaceCoords, surface.tilt, surface.azimuth); return(memSurface); }
public static MemorySafe_CartCoord convertToMemorySafeCoord(CartCoord coord) { MemorySafe_CartCoord memCoord = new MemorySafe_CartCoord(coord.X, coord.Y, coord.Z); return memCoord; }
public static double GetAreaofSurface(MemorySafe_Surface surface) { //Used to figure out how best to calculate the area from a given surfacce. //Get the coordinates that define the surface //get the area based on the coordinates //Get the RHRVector (the actual direction is not important MemorySafe_CartVect RHRVector = GetRHR(surface.SurfaceCoords); //now that I have this, I can move on //there are two basic cases for calculating the area that we cover here, //one where we get the area using greens theorem when the surface is parallel to one of the axes of the project global reference frame //and the second where the surface is not parallel to one of the axes of the global reference frame //Surface normal Parallel to global reference frame X Axis if (Math.Abs(RHRVector.X) == 1 && RHRVector.Y == 0 && RHRVector.Z == 0) { List<MemorySafe_CartCoord> coordList = new List<MemorySafe_CartCoord>(); for (int i = 0; i < surface.SurfaceCoords.Count; i++) { //only take the Y and Z coordinates and throw out the X because we can assume that they are all the same double X = 0; double Y = surface.SurfaceCoords[i].Y; double Z = surface.SurfaceCoords[i].Z; MemorySafe_CartCoord coord = new MemorySafe_CartCoord(X, Y, Z); coordList.Add(coord); } double area = GetAreaFrom2DPolyLoop(coordList); return area; } //Surface normal Parallel to global reference frame y Axis else if (RHRVector.X == 0 && Math.Abs(RHRVector.Y) == 1 && RHRVector.Z == 0) { List<MemorySafe_CartCoord> coordList = new List<MemorySafe_CartCoord>(); for (int i = 0; i < surface.SurfaceCoords.Count; i++) { //only take the X and Z coordinates and throw out the Y because we can assume that they are all the same double X = surface.SurfaceCoords[i].X; double Y = 0; double Z = surface.SurfaceCoords[i].Z; MemorySafe_CartCoord coord = new MemorySafe_CartCoord(X, Y, Z); coordList.Add(coord); } double area = GetAreaFrom2DPolyLoop(coordList); return area; } else if (RHRVector.X == 0 && RHRVector.Y == 0 && Math.Abs(RHRVector.Z) == 1) { List<MemorySafe_CartCoord> coordList = new List<MemorySafe_CartCoord>(); for (int i = 0; i < surface.SurfaceCoords.Count; i++) { //only take the X and Y coordinates and throw out the Z because we can assume that they are all the same double X = surface.SurfaceCoords[i].X; double Y = surface.SurfaceCoords[i].Y; double Z = 0; MemorySafe_CartCoord coord = new MemorySafe_CartCoord(X, Y, Z); coordList.Add(coord); } double area = GetAreaFrom2DPolyLoop(coordList); return area; } //the surface is not aligned with one of the reference frame axes, which requires a bit more work to determine the right answer. else { //New Z Axis for this plane is the normal vector already calculated, does not need to be created //Get New Y Axis which is the surface Normal Vector cross the original global reference X unit vector (all unit vectors please double X = 1; double Y = 0; double Z = 0; MemorySafe_CartVect globalReferenceX = new MemorySafe_CartVect(X, Y, Z); MemorySafe_CartVect localY = CrossProduct(RHRVector, globalReferenceX); localY = UnitVector(localY); //new X axis is the localY cross the surface normal vector MemorySafe_CartVect localX = CrossProduct(localY, RHRVector); localX = UnitVector(localX); //convert the polyloop coordinates to a local 2-D reference frame //using a trick employed by video game programmers found here http://stackoverflow.com/questions/1023948/rotate-normal-vector-onto-axis-plane List<MemorySafe_CartCoord> translatedCoordinates = new List<MemorySafe_CartCoord>(); //put the origin in place in these translated coordinates since our loop skips over this first arbitrary point double originX = 0; double originY = 0; double originZ = 0; MemorySafe_CartCoord newOrigin = new MemorySafe_CartCoord(originX, originY, originZ); translatedCoordinates.Add(newOrigin); for (int j = 1; j < surface.SurfaceCoords.Count; j++) { //randomly assigns the first polyLoop coordinate as the origin MemorySafe_CartCoord origin = surface.SurfaceCoords[0]; //captures the components of a vector drawn from the new origin to the double xDistance = surface.SurfaceCoords[j].X - origin.X; double yDist = surface.SurfaceCoords[j].Y - origin.Y; double zDist = surface.SurfaceCoords[j].Z - origin.Z; MemorySafe_CartVect distance = new MemorySafe_CartVect(xDistance, yDist, zDist); double translPtX = distance.X * localX.X + distance.Y * localX.Y + distance.Z * localX.Z; double translPtY = distance.X * localY.X + distance.Y * localY.Y + distance.Z * localY.Z; double translPtZ = 0; MemorySafe_CartCoord translatedPt = new MemorySafe_CartCoord(translPtX, translPtY, translPtZ); translatedCoordinates.Add(translatedPt); } double area = GetAreaFrom2DPolyLoop(translatedCoordinates); return area; } }
public static double GetAreaofSurface(MemorySafe_Surface surface) { //Used to figure out how best to calculate the area from a given surfacce. //Get the coordinates that define the surface //get the area based on the coordinates //Get the RHRVector (the actual direction is not important MemorySafe_CartVect RHRVector = GetRHR(surface.SurfaceCoords); //now that I have this, I can move on //there are two basic cases for calculating the area that we cover here, //one where we get the area using greens theorem when the surface is parallel to one of the axes of the project global reference frame //and the second where the surface is not parallel to one of the axes of the global reference frame //Surface normal Parallel to global reference frame X Axis if (Math.Abs(RHRVector.X) == 1 && RHRVector.Y == 0 && RHRVector.Z == 0) { List <MemorySafe_CartCoord> coordList = new List <MemorySafe_CartCoord>(); for (int i = 0; i < surface.SurfaceCoords.Count; i++) { //only take the Y and Z coordinates and throw out the X because we can assume that they are all the same double X = 0; double Y = surface.SurfaceCoords[i].Y; double Z = surface.SurfaceCoords[i].Z; MemorySafe_CartCoord coord = new MemorySafe_CartCoord(X, Y, Z); coordList.Add(coord); } double area = GetAreaFrom2DPolyLoop(coordList); return(area); } //Surface normal Parallel to global reference frame y Axis else if (RHRVector.X == 0 && Math.Abs(RHRVector.Y) == 1 && RHRVector.Z == 0) { List <MemorySafe_CartCoord> coordList = new List <MemorySafe_CartCoord>(); for (int i = 0; i < surface.SurfaceCoords.Count; i++) { //only take the X and Z coordinates and throw out the Y because we can assume that they are all the same double X = surface.SurfaceCoords[i].X; double Y = 0; double Z = surface.SurfaceCoords[i].Z; MemorySafe_CartCoord coord = new MemorySafe_CartCoord(X, Y, Z); coordList.Add(coord); } double area = GetAreaFrom2DPolyLoop(coordList); return(area); } else if (RHRVector.X == 0 && RHRVector.Y == 0 && Math.Abs(RHRVector.Z) == 1) { List <MemorySafe_CartCoord> coordList = new List <MemorySafe_CartCoord>(); for (int i = 0; i < surface.SurfaceCoords.Count; i++) { //only take the X and Y coordinates and throw out the Z because we can assume that they are all the same double X = surface.SurfaceCoords[i].X; double Y = surface.SurfaceCoords[i].Y; double Z = 0; MemorySafe_CartCoord coord = new MemorySafe_CartCoord(X, Y, Z); coordList.Add(coord); } double area = GetAreaFrom2DPolyLoop(coordList); return(area); } //the surface is not aligned with one of the reference frame axes, which requires a bit more work to determine the right answer. else { //New Z Axis for this plane is the normal vector already calculated, does not need to be created //Get New Y Axis which is the surface Normal Vector cross the original global reference X unit vector (all unit vectors please double X = 1; double Y = 0; double Z = 0; MemorySafe_CartVect globalReferenceX = new MemorySafe_CartVect(X, Y, Z); MemorySafe_CartVect localY = CrossProduct(RHRVector, globalReferenceX); localY = UnitVector(localY); //new X axis is the localY cross the surface normal vector MemorySafe_CartVect localX = CrossProduct(localY, RHRVector); localX = UnitVector(localX); //convert the polyloop coordinates to a local 2-D reference frame //using a trick employed by video game programmers found here http://stackoverflow.com/questions/1023948/rotate-normal-vector-onto-axis-plane List <MemorySafe_CartCoord> translatedCoordinates = new List <MemorySafe_CartCoord>(); //put the origin in place in these translated coordinates since our loop skips over this first arbitrary point double originX = 0; double originY = 0; double originZ = 0; MemorySafe_CartCoord newOrigin = new MemorySafe_CartCoord(originX, originY, originZ); translatedCoordinates.Add(newOrigin); for (int j = 1; j < surface.SurfaceCoords.Count; j++) { //randomly assigns the first polyLoop coordinate as the origin MemorySafe_CartCoord origin = surface.SurfaceCoords[0]; //captures the components of a vector drawn from the new origin to the double xDistance = surface.SurfaceCoords[j].X - origin.X; double yDist = surface.SurfaceCoords[j].Y - origin.Y; double zDist = surface.SurfaceCoords[j].Z - origin.Z; MemorySafe_CartVect distance = new MemorySafe_CartVect(xDistance, yDist, zDist); double translPtX = distance.X * localX.X + distance.Y * localX.Y + distance.Z * localX.Z; double translPtY = distance.X * localY.X + distance.Y * localY.Y + distance.Z * localY.Z; double translPtZ = 0; MemorySafe_CartCoord translatedPt = new MemorySafe_CartCoord(translPtX, translPtY, translPtZ); translatedCoordinates.Add(translatedPt); } double area = GetAreaFrom2DPolyLoop(translatedCoordinates); return(area); } }
public static MemorySafe_CartCoord convertToMemorySafeCoord(CartCoord coord) { MemorySafe_CartCoord memCoord = new MemorySafe_CartCoord(coord.X, coord.Y, coord.Z); return(memCoord); }