DLA-Fire-Prediction-Thesis 1.0
|
This class build the DLA structure in the specific area, wind direction and size. More...
#include <DLAStructure.h>
Public Member Functions | |
DLAStructure () | |
default ctor of DLA structure | |
DLAStructure (std::vector< FuelPoint > _gridPointList, std::vector< FuelObject > _objectPointList, ngl::Vector _originPoint, int _sceneWidth, int _sceneHeight, float _pointRadius, int _dlaSize, ngl::Vector _windDirection, int _windSpeed) | |
ctor of DLA structure | |
DLAStructure (std::vector< FuelPoint > _gridPointList, std::vector< FuelObject > _objectPointList, ngl::Vector _originPoint, int _sceneWidth, int _sceneHeight, float _pointRadius, std::vector< FuelPoint > _previousDLAPoint, std::vector< FuelPoint > _otherOriginList, int _currentOriginIndex, int _dlaSize, ngl::Vector _windDirection, int _windSpeed) | |
ctor of DLA structure | |
void | findPath (FuelPoint m_originPoint) |
This method will find the next dla point. | |
void | assignDLA (ngl::Vector m_newDLAPoint, ngl::Vector m_seed, int m_generationNumber) |
This method will apply the new dla point to the dla list with the specific generation number. | |
ngl::Vector | moveRandomPoint (ngl::Vector m_currentPoint, int m_mode) |
This method will move the current random point to the new random position. | |
int | findFarthestPos (int m_numberOne, int m_numberTwo, int m_numberThree) |
This method will find the farthest side of given position. | |
int | findMaximumSide (ngl::Vector m_travelerPos, ngl::Vector m_seedPos) |
This method will find the farthest distance side between two given position. | |
int | findSideOfMaximumPosition (ngl::Vector m_travelerPos, ngl::Vector m_seedPos, int m_maximumSide) |
This method will find the side of current traveler point that should not move. | |
int | checkCollision (ngl::Vector m_travelerPos) |
This method will check each time step when the traveler randomly moved that it is hit any dla point or not. | |
ngl::Vector | getRandomPosition (ngl::Vector m_currentPos, float m_radius, int m_randomMode) |
This method will find the random point in the area of specific circle around the origin point. | |
float | setDecimalValue (float m_number, int m_decimalPlaces) |
This method will set the specific number to have the specific decimal places. | |
ngl::Vector | checkBoundary (ngl::Vector m_newDLAPoint) |
This method will check if the fire path goes further than the boundary area or not. If yes, the path at the edge will be assigned. | |
int | checkCollisionWithNonFlammableObject (ngl::Vector m_newDLAPoint) |
This method will check the collision with non-flammable object. | |
void | adaptPoint () |
This method will adjust the position of DLA point on flat grid with the terrain height. | |
float | getCurrentYPos (ngl::Vector m_currentDLAPos) |
This method will compare current point on flat grid to the point list of terrain and then the new Y-position will be returned. | |
std::vector< FuelPoint > | getDLAList () |
This method will return the DLA list. | |
std::vector< FuelPoint > | getDLALine () |
This method will return the DLA list that represents as the seed of each following point. | |
void | arrangeList () |
This method will sort the DLA List with respecting to its generation number. | |
int | checkCollisionWithOtherDLA (ngl::Vector m_newDLAPoint) |
This method will check the collision with other DLA structure. | |
int | checkCollisionWithOtherOrigin (ngl::Vector m_newDLAPoint) |
This method will check the collision with other Origin Point. | |
Private Attributes | |
int | m_sceneWidth |
width size of fire area | |
int | m_sceneHeight |
height size of fire area | |
std::vector< FuelPoint > | m_scenePointList |
the list contains all points on the scene that are available to catch the fire | |
std::vector< FuelPoint > | m_dlaLine |
the list contians the seed point of each new dla points | |
std::vector< FuelPoint > | m_dlaList |
the list contains the new dla points | |
std::vector< FuelObject > | m_objList |
the list contains the fuel objects | |
float | m_circleRadius |
radius of circle for the random point area in dla progress | |
float | m_pointRadius |
radius of the point | |
float | m_dlaPointDistance |
radius between dla point or the distance between each dla point | |
int | m_dlaSize |
size of dla per origin point | |
ngl::Vector | m_originSeed |
the origin point position | |
std::vector< FuelPoint > | m_otherOriginList |
the list of origin point on the whold fire area | |
bool | m_checkForm |
the flag to check the building DLA structure with other built DLA structure | |
ngl::Vector | m_windDir |
the wind direction | |
int | m_windSpeed |
the wind speed | |
bool | m_windEnabled |
the wind flag | |
std::vector< FuelPoint > | m_previousDLAList |
the list of point on previous DLA structure | |
int | m_currentOriginIndex |
the current index of origin | |
int | m_distanceForm |
the appropriate distance of DLA point |
This class build the DLA structure in the specific area, wind direction and size.
Definition at line 30 of file DLAStructure.h.
DLAStructure::DLAStructure | ( | ) |
default ctor of DLA structure
Definition at line 20 of file DLAStructure.cpp.
References findPath(), m_checkForm, m_circleRadius, m_dlaLine, m_dlaList, m_dlaPointDistance, m_dlaSize, m_objList, m_originSeed, m_pointRadius, m_sceneHeight, m_scenePointList, and m_sceneWidth.
{ // set list back to initial size std::vector<FuelObject> m_objZero; m_objList = m_objZero; std::vector<FuelPoint> m_pntZero; m_dlaLine = m_pntZero; m_dlaList = m_pntZero; m_scenePointList = m_pntZero; m_originSeed = ngl::Vector(0.0,0.0,0.0); m_scenePointList.push_back(FuelPoint(m_originSeed, 0)); m_objList.push_back(FuelObject(ngl::Vector(4.0,0.0,0.0), 0, 1)); m_sceneWidth = 30; m_sceneHeight = 30; m_pointRadius = 0.1; m_circleRadius = 2.0; m_dlaPointDistance = m_pointRadius*2; m_dlaSize = 800; m_checkForm = false; std::cout<<"...Please Be Patient the Fire Path is Building..."<<std::endl; FuelPoint m_origin = m_scenePointList[0]; findPath(m_origin); }
DLAStructure::DLAStructure | ( | std::vector< FuelPoint > | _gridPointList, |
std::vector< FuelObject > | _objectPointList, | ||
ngl::Vector | _originPoint, | ||
int | _sceneWidth, | ||
int | _sceneHeight, | ||
float | _pointRadius, | ||
int | _dlaSize, | ||
ngl::Vector | _windDirection, | ||
int | _windSpeed | ||
) |
ctor of DLA structure
_gridPointList | is the list of every point in the scene |
_objectPointList | is the list of object position on the scene |
_originPoint | is the origin position |
_scenceWidth | is the width size of the scene |
_sceneHeight | is the height size of the scene |
_pointRadius | is the radius of point on the scene and the distance between point for DLA |
_dlaSize | is the size of DLA as the input of user |
_windDirection | is the wind direction of the scene |
_windSpeed | is the wind speed of the scene |
Definition at line 52 of file DLAStructure.cpp.
References adaptPoint(), arrangeList(), findPath(), m_checkForm, m_circleRadius, m_currentOriginIndex, m_distanceForm, m_dlaLine, m_dlaList, m_dlaPointDistance, m_dlaSize, m_objList, m_originSeed, m_pointRadius, m_sceneHeight, m_scenePointList, m_sceneWidth, m_windDir, m_windEnabled, and m_windSpeed.
{ // set list back to initial size std::vector<FuelObject> m_objZero; m_objList = m_objZero; std::vector<FuelPoint> m_pntZero; m_dlaLine = m_pntZero; m_dlaList = m_pntZero; m_scenePointList = m_pntZero; // assign origin point m_originSeed = _originPoint; m_scenePointList.push_back(FuelPoint(m_originSeed, 0)); FuelPoint m_origin = m_scenePointList[0]; // assign terrain point to the list m_scenePointList = _gridPointList; m_windDir = _windDirection; m_windSpeed = _windSpeed; if(m_windDir.m_y<=10) m_windEnabled = true; else m_windEnabled = false; m_objList = _objectPointList; m_sceneWidth = _sceneWidth; m_sceneHeight = _sceneHeight; m_pointRadius = _pointRadius; m_currentOriginIndex = 0; m_distanceForm = 1.4; m_circleRadius = 2.0; m_dlaPointDistance = m_pointRadius*2; m_dlaSize = _dlaSize; m_checkForm = false; std::cout<<"...Please Be Patient the Fire Path is Building..."<<std::endl; findPath(m_origin); adaptPoint(); arrangeList(); }
DLAStructure::DLAStructure | ( | std::vector< FuelPoint > | _gridPointList, |
std::vector< FuelObject > | _objectPointList, | ||
ngl::Vector | _originPoint, | ||
int | _sceneWidth, | ||
int | _sceneHeight, | ||
float | _pointRadius, | ||
std::vector< FuelPoint > | _previousDLAPoint, | ||
std::vector< FuelPoint > | _otherOriginList, | ||
int | _currentOriginIndex, | ||
int | _dlaSize, | ||
ngl::Vector | _windDirection, | ||
int | _windSpeed | ||
) |
ctor of DLA structure
_gridPointList | is the list of every point in the scene |
_objectPointList | is the list of object position on the scene |
_originPoint | is the origin position |
_scenceWidth | is the width size of the scene |
_sceneHeight | is the height size of the scene |
_pointRadius | is the radius of point on the scene and the distance between point for DLA |
_previousDLAPoint | is the list of previous DLA form that was generated |
_otherOriginList | is the list of all origin points on the scene |
_currentOriginIndex | is the current index from origin list |
_dlaSize | is the size of DLA as the input of user |
_windDirection | is the wind direction of the scene |
_windSpeed | is the wind speed of the scene |
Definition at line 111 of file DLAStructure.cpp.
References adaptPoint(), arrangeList(), findPath(), m_checkForm, m_circleRadius, m_currentOriginIndex, m_distanceForm, m_dlaLine, m_dlaList, m_dlaPointDistance, m_dlaSize, m_objList, m_originSeed, m_otherOriginList, m_pointRadius, m_previousDLAList, m_sceneHeight, m_scenePointList, m_sceneWidth, m_windDir, m_windEnabled, and m_windSpeed.
{ // set list back to initial size std::vector<FuelObject> m_objZero; m_objList = m_objZero; std::vector<FuelPoint> m_pntZero; m_dlaLine = m_pntZero; m_dlaList = m_pntZero; m_scenePointList = m_pntZero; // assign origin point m_originSeed = _originPoint; m_scenePointList.push_back(FuelPoint(m_originSeed, 0)); FuelPoint m_origin = m_scenePointList[0]; // assign terrain point to the list m_scenePointList = _gridPointList; m_windDir = _windDirection; m_windSpeed = _windSpeed; if(m_windDir.m_y<=10) m_windEnabled = true; else m_windEnabled = false; m_objList = _objectPointList; m_sceneWidth = _sceneWidth; m_sceneHeight = _sceneHeight; m_pointRadius = _pointRadius; m_circleRadius = 2.0; m_dlaPointDistance = m_pointRadius*2; m_dlaSize = _dlaSize; m_distanceForm = 0.0; m_checkForm = true; m_otherOriginList = _otherOriginList; m_currentOriginIndex = _currentOriginIndex; m_previousDLAList = _previousDLAPoint; std::cout<<"...Please Be Patient the Fire Path is Building..."<<std::endl; findPath(m_origin); adaptPoint(); arrangeList(); }
void DLAStructure::adaptPoint | ( | ) |
This method will adjust the position of DLA point on flat grid with the terrain height.
Definition at line 178 of file DLAStructure.cpp.
References FuelPoint::getBurningTime(), getCurrentYPos(), FuelPoint::getGeneration(), FuelPoint::getPosition(), m_dlaLine, m_dlaList, FuelPoint::setBurningTime(), FuelPoint::setGeneration(), and FuelPoint::setPosition().
{ // ----- deal with m_dlaList, m_dlaLine, and m_scenePointList for(unsigned int s=0; s<m_dlaList.size(); ++s) { FuelPoint m_dlaPoint = m_dlaList[s]; ngl::Vector m_dlaPos = m_dlaPoint.getPosition(); float m_adaptedYPos = getCurrentYPos(m_dlaPos); m_dlaPos.m_y = m_adaptedYPos; m_dlaPoint.setPosition(m_dlaPos); m_dlaList[s] = m_dlaPoint; } for(unsigned int t=0; t<m_dlaLine.size(); ++t) { FuelPoint m_dlaPoint = m_dlaLine[t]; ngl::Vector m_dlaPos = m_dlaPoint.getPosition(); float m_adaptedYPos = getCurrentYPos(m_dlaPos); m_dlaPos.m_y = m_adaptedYPos; m_dlaPoint.setPosition(m_dlaPos); m_dlaLine[t] = m_dlaPoint; } // ----- insert new burning time, refers to the slope for(unsigned int r=0; r<m_dlaLine.size(); ++r) { FuelPoint m_firstPoint = m_dlaList[r]; ngl::Vector m_firstPointPos = m_firstPoint.getPosition(); FuelPoint m_secondPoint = m_dlaLine[r]; ngl::Vector m_secondPointPos = m_secondPoint.getPosition(); float m_firstYPos = m_firstPointPos.m_y;//*1000; float m_secondYPos = m_secondPointPos.m_y;//*1000; float m_diffYLevel = m_secondYPos - m_firstYPos; int m_adjustValue = m_diffYLevel/0.1; float m_firstPointBurningTime = m_firstPoint.getBurningTime(); float m_newBurningTime = m_firstPointBurningTime + m_adjustValue; m_firstPoint.setBurningTime(m_newBurningTime); m_dlaList[r] = m_firstPoint; m_secondPoint.setBurningTime(m_newBurningTime); m_dlaLine[r] = m_secondPoint; } // ----- manage generation for(unsigned int u=0; u<m_dlaList.size(); ++u) { FuelPoint m= m_dlaList[u]; // decrease the generation if(m.getBurningTime()<10) { // get suitable generation FuelPoint m_headLine = m_dlaLine[u]; ngl::Vector m_headLinePos = m_headLine.getPosition(); int m_index = 0; for(unsigned int j=0; j<m_dlaList.size(); ++j) { FuelPoint m_previousPoint = m_dlaList[j]; ngl::Vector m_previousPointPos = m_previousPoint.getPosition(); if((m_previousPointPos.m_x==m_headLinePos.m_x)&&(m_previousPointPos.m_z==m_headLinePos.m_z)) m_index = j; } FuelPoint m_headPoint = m_dlaList[m_index]; int m_currentGen = m_headPoint.getGeneration(); // decrease burning time m.setBurningTime(m.getBurningTime()-5); m.setGeneration(m_currentGen); m_dlaList[u] = m; FuelPoint m_line = m_dlaLine[u]; m_line.setGeneration(m_currentGen); m_dlaLine[u] = m_line; } else if(m.getBurningTime()>10) { int m_currentGen = m.getGeneration(); // decrease burning time // m.setBurningTime(m.getBurningTime()-2); m.setGeneration(m_currentGen+1); m_dlaList[u] = m; FuelPoint m_line = m_dlaLine[u]; m_line.setGeneration(m_currentGen+1); m_dlaLine[u] = m_line; } else { // decrease burning time // m.setBurningTime(m.getBurningTime()-3); //int m_currentGen = m.getGeneration(); // m.setGeneration(m_currentGen+1); m_dlaList[u] = m; FuelPoint m_line = m_dlaLine[u]; // m_line.setGeneration(m_currentGen+1); m_dlaLine[u] = m_line; } // end if-elst burning time condition } // end for loop of generation number managing }
void DLAStructure::arrangeList | ( | ) |
This method will sort the DLA List with respecting to its generation number.
Definition at line 1003 of file DLAStructure.cpp.
References FuelPoint::getGeneration(), FuelPoint::getPosition(), m_dlaLine, m_dlaList, and FuelPoint::setPosition().
{ // get maximum generation int m_generationCounterForHeadLine=0; for(unsigned int k=0; k<m_dlaLine.size(); ++k) { FuelPoint m = m_dlaLine[k]; if(m_generationCounterForHeadLine<m.getGeneration()) m_generationCounterForHeadLine = m.getGeneration(); } // put the generation counter to the first point of the list at the value of w FuelPoint m_firstPointLine = m_dlaLine[0]; ngl::Vector m_firstLine = m_firstPointLine.getPosition(); m_firstLine.m_w = m_generationCounterForHeadLine; m_firstPointLine.setPosition(m_firstLine); m_dlaLine[0] = m_firstPointLine; int m_generationCounter = 0; for(unsigned int j=0; j<m_dlaList.size(); ++j) { FuelPoint n = m_dlaList[j]; if(m_generationCounter<n.getGeneration()) m_generationCounter = n.getGeneration(); } m_firstPointLine = m_dlaList[0]; m_firstLine = m_firstPointLine.getPosition(); m_firstLine.m_w = m_generationCounterForHeadLine; m_firstPointLine.setPosition(m_firstLine); m_dlaList[0] = m_firstPointLine; // ----- sort the dlaList list std::vector<FuelPoint> m_dlaArrangedList; // arrange the list for(int g=0; g<=m_generationCounter; ++g) { std::vector<FuelPoint> m_arrangedList; for(unsigned int h=0; h<m_dlaList.size(); ++h) { FuelPoint m_genPoint = m_dlaList[h]; int m_genNumber = m_genPoint.getGeneration(); if(m_genNumber==g) m_arrangedList.push_back(m_genPoint); } // input the list if(g==0) { m_dlaArrangedList = m_arrangedList; } else { for(unsigned int e=0; e<m_arrangedList.size(); ++e) { FuelPoint m_arrangePoint = m_arrangedList[e]; m_dlaArrangedList.push_back(m_arrangePoint); } // end for loop } // end if-else } // end for loop arrange list m_dlaList = m_dlaArrangedList; // ----- sort the dlaLine list std::vector<FuelPoint> m_dlaArrangedLine; // arrange the list for(int g=0; g<=m_generationCounterForHeadLine; ++g) { std::vector<FuelPoint> m_arrangedLine; for(unsigned int h=0; h<m_dlaLine.size(); ++h) { FuelPoint m_genPoint = m_dlaLine[h]; int m_genNumber = m_genPoint.getGeneration(); if(m_genNumber==g) m_arrangedLine.push_back(m_genPoint); } // input the list if(g==0) { m_dlaArrangedLine = m_arrangedLine; } else { for(unsigned int e=0; e<m_arrangedLine.size(); ++e) { FuelPoint m_arrangePoint = m_arrangedLine[e]; m_dlaArrangedLine.push_back(m_arrangePoint); } // end for loop } // end if-else } // end for loop arrange list m_dlaLine = m_dlaArrangedLine; }
void DLAStructure::assignDLA | ( | ngl::Vector | m_newDLAPoint, |
ngl::Vector | m_seed, | ||
int | m_generationNumber | ||
) |
This method will apply the new dla point to the dla list with the specific generation number.
m_newDLAPoint | is the position of new dla point |
m_seed | is the position of dla seed point |
m_generationNumber | is the current generation number that would be added to the new dla point |
Definition at line 729 of file DLAStructure.cpp.
References FuelPoint::getBurningTime(), m_dlaLine, m_dlaList, m_originSeed, m_windDir, m_windEnabled, m_windSpeed, FuelPoint::setBurningTime(), and FuelPoint::setGeneration().
{ // insert the distance from origin ngl::Vector m_distanceFromOrigin = m_newDLAPoint - m_originSeed; float m_distanceFarFromOrigin = m_distanceFromOrigin.length(); bool m_addToList = true; float m_intDist = m_distanceFarFromOrigin*100; m_distanceFarFromOrigin = round(m_intDist); m_distanceFarFromOrigin = m_distanceFarFromOrigin/100; m_newDLAPoint.m_w = m_distanceFarFromOrigin; m_distanceFromOrigin = m_seed - m_originSeed; m_distanceFarFromOrigin = m_distanceFromOrigin.length(); m_intDist = m_distanceFarFromOrigin*100; m_distanceFarFromOrigin = round(m_intDist); m_distanceFarFromOrigin = m_distanceFarFromOrigin/100; m_seed.m_w = m_distanceFarFromOrigin; //ngl::Vector m_betPoint = m_newDLAPoint - m_seed; //float m_betDist = m_betPoint.length(); //if((m_betDist<0.15)&&(m_dlaList.size()>10)) { //m_addToList = false; } if(m_addToList==true) { m_dlaList.push_back(FuelPoint(m_newDLAPoint,0)); m_dlaLine.push_back(FuelPoint(m_seed, 0)); } int m_burningTime = 0; // ----- check if the new assigned point goes against the wind or not if(m_windEnabled==true) { ngl::Vector m_windDirection = ngl::Vector(0.0,0.0,0.0) - m_windDir; ngl::Vector m_windUnitVector = m_windDirection/m_windDirection.length(); ngl::Vector m_fireDirection = m_seed - m_newDLAPoint; bool m_negativeZ = false; bool m_negativeX = false; if(m_windUnitVector.m_x<0) m_negativeX = true; if(m_windUnitVector.m_z<0) m_negativeZ = true; bool m_changeX = false; bool m_changeZ = false; if(m_negativeX==true) { if(m_fireDirection.m_x<0) { m_changeX = false; } else { m_changeX = true; } } else { if(m_fireDirection.m_x>=0) { m_changeX = false; } else { m_changeX = true; } }// end if x change if(m_negativeZ==true) { if(m_fireDirection.m_z<0) { m_changeZ = false; } else { m_changeZ = true; } } else { if(m_fireDirection.m_z>=0) { m_changeZ = false; } else { m_changeZ = true; } } // end if z change int m_speed = m_windSpeed; if((m_windSpeed>1)&&(m_windSpeed<=6)) { m_speed = m_windSpeed*1.6; } else if((m_windSpeed>6)&&(m_windSpeed<=9)) { m_speed = m_windSpeed*1.4; } else { m_speed = m_windSpeed*1.2; } if((m_changeX==true)&&(m_changeZ==true)) { m_generationNumber += m_speed; } else if(((m_changeX==true)&&(m_changeZ==false))||((m_changeX==false)&&(m_changeZ==true))) { m_generationNumber += 2; } } // end if wind is enabled if(m_addToList==true) { // ----- set the generation FuelPoint m_firePoint = m_dlaList[m_dlaList.size()-1]; m_firePoint.setGeneration(m_generationNumber+1); int m_currentBTime = m_firePoint.getBurningTime(); m_firePoint.setBurningTime(m_currentBTime+m_burningTime); m_dlaList[m_dlaList.size()-1] = m_firePoint; m_firePoint = m_dlaLine[m_dlaLine.size()-1]; m_firePoint.setGeneration(m_generationNumber+1); m_dlaLine[m_dlaLine.size()-1] = m_firePoint; } }
ngl::Vector DLAStructure::checkBoundary | ( | ngl::Vector | m_newDLAPoint | ) |
This method will check if the fire path goes further than the boundary area or not. If yes, the path at the edge will be assigned.
m_newDLAPoint | is the current position of traveller that is going to stick with DLA structure soon. |
Definition at line 587 of file DLAStructure.cpp.
References m_sceneHeight, and m_sceneWidth.
{ float m_xValue = m_newDLAPoint.m_x; float m_yValue = m_newDLAPoint.m_y; float m_zValue = m_newDLAPoint.m_z; if(m_xValue<(-m_sceneWidth/10)) m_xValue = -m_sceneWidth/10; if(m_xValue>(m_sceneWidth/10)-0.2) m_xValue = (m_sceneWidth/10)-0.2; if(m_zValue<(-m_sceneHeight/10)) m_zValue = -m_sceneHeight/10; if(m_zValue>(m_sceneHeight/10)-0.2) m_zValue = (m_sceneHeight/10)-0.2; return ngl::Vector(m_xValue, m_yValue, m_zValue); }
int DLAStructure::checkCollision | ( | ngl::Vector | m_travelerPos | ) |
This method will check each time step when the traveler randomly moved that it is hit any dla point or not.
m_travelerPos | is the current position of traveler |
Definition at line 637 of file DLAStructure.cpp.
References FuelPoint::getPosition(), and m_dlaList.
{ ngl::Vector m_randomPos = m_travelerPos; int m_seedIndex = 0; float m_minTempDistance = 1000000.0; // check if it is hit anything // and find the closest point // collision checking for(unsigned int t=0; t<m_dlaList.size(); ++t) { FuelPoint m_tempHitPoint = m_dlaList[t]; ngl::Vector m_tempHitPos = m_tempHitPoint.getPosition(); ngl::Vector m_tempDelta = m_randomPos - m_tempHitPos; float m_tempDistance = m_tempDelta.length(); if(m_tempDistance<m_minTempDistance) { m_minTempDistance = m_tempDistance; m_seedIndex = t; } } return m_seedIndex; }
int DLAStructure::checkCollisionWithNonFlammableObject | ( | ngl::Vector | m_newDLAPoint | ) |
This method will check the collision with non-flammable object.
m_newDLAPoint | is the current position of traveller |
Definition at line 951 of file DLAStructure.cpp.
References FuelObject::getPosition(), FuelObject::getRadius(), FuelObject::getShape(), and m_objList.
{ int m_isCollided = 0; for(unsigned int d=0; d<m_objList.size(); ++d) { FuelObject m_objectPoint = m_objList[d]; ngl::Vector m_objectPos = m_objectPoint.getPosition(); float m_objectRadius = m_objectPoint.getRadius() + 0.1; ngl::Vector m_delta= m_newDLAPoint - m_objectPos; float m_distance = m_delta.length(); if(m_objectPoint.getShape()==2) { m_distance = m_objectRadius; float m_plusX = m_objectPos.m_x + m_objectRadius; float m_minusX = m_objectPos.m_x - m_objectRadius; float m_plusZ = m_objectPos.m_z + m_objectRadius; float m_minusZ = m_objectPos.m_z - m_objectRadius; if(m_newDLAPoint.m_x<m_plusX && m_newDLAPoint.m_x>m_minusX) if(m_newDLAPoint.m_z<m_plusZ && m_newDLAPoint.m_z>m_minusZ) m_isCollided = 1; } // if it is collided if(m_distance<m_objectRadius) m_isCollided = 1; } return m_isCollided; }
int DLAStructure::checkCollisionWithOtherDLA | ( | ngl::Vector | m_newDLAPoint | ) |
This method will check the collision with other DLA structure.
m_newDLAPoint | is the current traveller |
Definition at line 1105 of file DLAStructure.cpp.
References FuelPoint::getPosition(), and m_previousDLAList.
{ int m_isCollided = 0; for(unsigned int r=0; r<m_previousDLAList.size(); ++r) { FuelPoint m_previousDLA = m_previousDLAList[r]; ngl::Vector m_previousDLAPos = m_previousDLA.getPosition(); ngl::Vector m_deltaPreviousDLA = m_newDLAPoint - m_previousDLAPos; float m_distacePreviousDLA = m_deltaPreviousDLA.length(); if(m_distacePreviousDLA<0.5) m_isCollided = 1; } return m_isCollided; }
int DLAStructure::checkCollisionWithOtherOrigin | ( | ngl::Vector | m_newDLAPoint | ) |
This method will check the collision with other Origin Point.
m_newDLAPoint | is the current traveller |
Definition at line 1128 of file DLAStructure.cpp.
References FuelPoint::getPosition(), m_currentOriginIndex, m_originSeed, and m_otherOriginList.
{ int m_isCollided = 0; for(unsigned int d=0; d<m_otherOriginList.size(); ++d) { if(d!=(unsigned)m_currentOriginIndex) { FuelPoint m_otherOriginPoint = m_otherOriginList[d]; ngl::Vector m_otherOriginPos = m_otherOriginPoint.getPosition(); // between origin ngl::Vector m_originDistance = m_originSeed - m_otherOriginPos; float m_otherOriginRadius = m_originDistance.length();//m_otherOriginPos.m_w; // if(m_windEnabled==true) // m_otherOriginRadius = 0.6; //else // m_otherOriginRadius *= 0.4; //if(m_otherOriginRadius>0.6) m_otherOriginRadius *= 0.4; ngl::Vector m_deltaPreviousDLA = m_newDLAPoint - m_otherOriginPos; float m_distacePreviousDLA = m_deltaPreviousDLA.length(); if(m_distacePreviousDLA<m_otherOriginRadius) m_isCollided = 1; } } return m_isCollided; }
int DLAStructure::findFarthestPos | ( | int | m_numberOne, |
int | m_numberTwo, | ||
int | m_numberThree | ||
) |
This method will find the farthest side of given position.
m_numberOne | is the distance position of x-orthogonal side |
m_numberTwo | is the distance position of y-orthogonal side |
m_numberThree | is the distance position of z-orthogonal side |
Definition at line 911 of file DLAStructure.cpp.
{ int m_max = 1; if(m_numberOne<m_numberTwo) { if(m_numberTwo<m_numberThree) { m_max = 3; } else { m_max = 2; } } else { m_max = 1; } return m_max; }
int DLAStructure::findMaximumSide | ( | ngl::Vector | m_travelerPos, |
ngl::Vector | m_seedPos | ||
) |
This method will find the farthest distance side between two given position.
m_travelerPos | is the current position of traveler |
m_seedPos | is the position of specific dla point |
Definition at line 611 of file DLAStructure.cpp.
References findFarthestPos().
{ ngl::Vector m_initRandomPos = m_travelerPos; ngl::Vector m_startPos = m_seedPos; // find the position and direction of random point float m_deltaX = m_initRandomPos.m_x - m_startPos.m_x; float m_deltaY = m_initRandomPos.m_y - m_startPos.m_y; float m_deltaZ = m_initRandomPos.m_z - m_startPos.m_z; int absX = m_deltaX*100; absX = abs(absX); int absY = m_deltaY*100; absY = abs(absY); int absZ = m_deltaZ*100; absZ = abs(absZ); int m_maximumSide = findFarthestPos(absX, absY, absZ); return m_maximumSide; }
void DLAStructure::findPath | ( | FuelPoint | m_originPoint | ) |
This method will find the next dla point.
End of function.
m_originPoint | is the origin point from the specific area or grid that wish to form the dla path |
---------------------------------------------------------------------------------------------------------------------- The following section is modified from :- Alasdair Turner (2009). Diffusion-limited aggregation [online]. [Accessed 18 July 2011]. Available from: <http://www.openprocessing.org/visuals/?visualID=1264>
end of Citation ----------------------------------------------------------------------------------------------------------------------
Definition at line 411 of file DLAStructure.cpp.
References assignDLA(), checkBoundary(), checkCollision(), checkCollisionWithNonFlammableObject(), checkCollisionWithOtherDLA(), checkCollisionWithOtherOrigin(), findMaximumSide(), findSideOfMaximumPosition(), FuelPoint::getGeneration(), FuelPoint::getPosition(), getRandomPosition(), m_checkForm, m_circleRadius, m_currentOriginIndex, m_distanceForm, m_dlaList, m_dlaPointDistance, m_dlaSize, m_originSeed, m_pointRadius, and moveRandomPoint().
{ ngl::Vector m_startPos = m_originPoint.getPosition(); //m_dlaList.push_back(m_originPoint); //m_dlaLine.push_back(m_originPoint); int m_generationNumber = 0; int m_iterationNumber = 0; bool m_takesTooLong = false; while(((unsigned)m_dlaList.size() <(unsigned) m_dlaSize)&&(m_takesTooLong==false)) { // get random position ngl::Vector m_initRandomPos = getRandomPosition(m_startPos, m_circleRadius, 1); int m_tempR = rand()%2 +1; if(m_tempR == 2) m_initRandomPos = getRandomPosition(m_startPos, m_circleRadius, -1); int m_nearIndex = 0; int m_movingStep = 0; bool m_near = false; int m_maximumSide = findMaximumSide(m_initRandomPos, m_startPos); // get the side of traveler position, according to seed point int m_side = findSideOfMaximumPosition(m_initRandomPos, m_startPos, m_maximumSide); int m_randomDirection = rand() % 6 +1; while(m_randomDirection==m_side || m_randomDirection==3 || m_randomDirection==4) //&& m_movingStep == 1) m_randomDirection = rand() % 6 +1; ngl::Vector m_deltaDistance = m_initRandomPos - m_startPos; float m_distance = m_deltaDistance.length(); std::vector<FuelPoint> m_collectingTraveler; if(m_distance<=m_dlaPointDistance) { // hit or closed assignDLA(m_initRandomPos, m_startPos, 0); } else { m_near = false; while(m_near==false) { int m_hitNonFlammable = 0; int m_hitOtherDLA = 0; int m_hitOtherOrigin = 0; std::vector<FuelPoint> m_tempTraveler; m_tempTraveler.push_back(m_originPoint); m_tempTraveler.push_back(FuelPoint(m_initRandomPos, 1)); // move until it is near the point while(m_near==false&&m_movingStep<200) { m_initRandomPos = moveRandomPoint(m_initRandomPos, m_randomDirection); ++m_movingStep; m_nearIndex = checkCollision(m_initRandomPos); if(m_nearIndex!=0) { FuelPoint m_newPoint = m_dlaList[m_nearIndex]; m_startPos = m_newPoint.getPosition(); m_generationNumber = m_newPoint.getGeneration(); } m_deltaDistance = m_initRandomPos - m_startPos; m_distance = m_deltaDistance.length(); // random for next round m_maximumSide = findMaximumSide(m_initRandomPos, m_startPos); m_side = findSideOfMaximumPosition(m_initRandomPos, m_startPos, m_maximumSide); m_randomDirection = rand()%6 +1; while(m_randomDirection==m_side || m_randomDirection==3|| m_randomDirection==4) m_randomDirection = rand() % 6 +1; // if the dla structure and its position is satisfied, with the distance and position if((m_distance<=m_dlaPointDistance)&&(m_distance>=m_pointRadius*m_distanceForm)) { m_near = true; // check if the fire goes out of world distance or not m_initRandomPos = checkBoundary(m_initRandomPos); // check if the fire hit non-frammable object m_hitNonFlammable = checkCollisionWithNonFlammableObject(m_initRandomPos); if(m_checkForm==true) { m_hitOtherDLA = checkCollisionWithOtherDLA(m_initRandomPos); m_hitOtherOrigin = checkCollisionWithOtherOrigin(m_initRandomPos); } m_deltaDistance = m_initRandomPos - m_startPos; m_distance = m_deltaDistance.length(); // check the distance that it would not collide to each other if(m_distance<=m_pointRadius || m_hitNonFlammable==1 || m_hitOtherDLA==1 || m_hitOtherOrigin==1) m_near = false; m_deltaDistance = m_initRandomPos - m_startPos; m_distance = m_deltaDistance.length(); } else m_near = false; m_tempTraveler.push_back(FuelPoint(m_initRandomPos, 0)); } // if still cannot find the random path to hit the point // get new random point if(m_near==false) { // reset moving step m_movingStep = 0; m_nearIndex = 0; // random new m_circleRadius // if change the plus value to 1.0, all the point will be hit int m_newRadius = rand()% (int)m_circleRadius + 2.0; m_tempR = rand()%2 + 1; if(m_tempR==2) { m_newRadius = rand()% (int)(m_circleRadius*3) + 3.0; } m_circleRadius = m_newRadius; m_generationNumber = 0; // set the startPos back to original position m_startPos = m_originPoint.getPosition(); m_initRandomPos = getRandomPosition(m_startPos, m_circleRadius, 1); m_tempR = rand()%2 +1; if(m_tempR == 2) m_initRandomPos = getRandomPosition(m_startPos, m_circleRadius, -1); } m_collectingTraveler = m_tempTraveler; } } // adjust new circle radius of random-sphere ngl::Vector m_farFromOrig = m_initRandomPos - m_originSeed; float m_posMag = m_farFromOrig.length(); if(m_posMag*1.5 >= m_circleRadius) m_circleRadius = m_posMag*1.5; assignDLA(m_initRandomPos, m_startPos, m_generationNumber); // set the startPos back to original position m_startPos = m_originPoint.getPosition(); // increase the iteration count ++m_iterationNumber; if(m_iterationNumber>=m_dlaSize*4) m_takesTooLong = true; } std::cout<<"Path number: "<<m_currentOriginIndex+1<<" Ready! dla size: "<<m_dlaList.size()<<std::endl; }
int DLAStructure::findSideOfMaximumPosition | ( | ngl::Vector | m_travelerPos, |
ngl::Vector | m_seedPos, | ||
int | m_maximumSide | ||
) |
This method will find the side of current traveler point that should not move.
because if it moves, it will go outside the limited area
m_travelerPos | is the current position of traveler |
m_seedPos | is the position of specific dla point |
m_maxmimumSide | is the side or location of traveler point position, according to the seed point |
Definition at line 667 of file DLAStructure.cpp.
{ ngl::Vector m_randomPos = m_travelerPos; ngl::Vector m_originPos = m_seedPos; int m_side = 0; // find sides of traveler, according to origin if(m_maximumSide==1) { // x if(m_randomPos.m_x<m_originPos.m_x) { m_side = 2; // negative side (left side) // no 2 for first move } else { m_side = 1; // positive side (right side) // no 1 for first move } } else if(m_maximumSide==2) { // y if(m_randomPos.m_y<m_originPos.m_y) { m_side = 4; // negative side (left side) } else { m_side = 3; // positive side (right side) } } else { // z if(m_randomPos.m_z<m_originPos.m_z) { m_side = 6; // negative side (left side) } else { m_side = 5; // positive side (right side) } } return m_side; }
float DLAStructure::getCurrentYPos | ( | ngl::Vector | m_currentDLAPos | ) |
This method will compare current point on flat grid to the point list of terrain and then the new Y-position will be returned.
m_currentDLAPos | is the current position that wishes to compare with terrain list. |
Definition at line 297 of file DLAStructure.cpp.
References FuelPoint::getPosition(), and m_scenePointList.
{ float m_yPos = m_currentDLAPos.m_y; int m_closedPointIndex = 0; float m_minimumDistance = 1000; // find the closest point for(unsigned int p=0; p<m_scenePointList.size(); ++p) { FuelPoint m_scenePoint = m_scenePointList[p]; ngl::Vector m_scenePos = m_scenePoint.getPosition(); m_scenePos.m_y = 0.0; m_currentDLAPos.m_y = 0.0; ngl::Vector m_deltaRange = m_scenePos - m_currentDLAPos; float m_distRange = m_deltaRange.length(); if(m_distRange<m_minimumDistance) { m_closedPointIndex = p; m_minimumDistance = m_distRange; } } FuelPoint m_closedPoint = m_scenePointList[m_closedPointIndex]; ngl::Vector m_closedPointPos = m_closedPoint.getPosition(); // check if the closest point is in non-flammable area m_yPos = m_closedPointPos.m_y + 0.1; return m_yPos; }
std::vector< FuelPoint > DLAStructure::getDLALine | ( | ) |
This method will return the DLA list that represents as the seed of each following point.
Definition at line 997 of file DLAStructure.cpp.
References m_dlaLine.
{ return m_dlaLine; }
std::vector< FuelPoint > DLAStructure::getDLAList | ( | ) |
This method will return the DLA list.
Definition at line 991 of file DLAStructure.cpp.
References m_dlaList.
{ return m_dlaList; }
ngl::Vector DLAStructure::getRandomPosition | ( | ngl::Vector | m_currentPos, |
float | m_radius, | ||
int | m_randomMode | ||
) |
This method will find the random point in the area of specific circle around the origin point.
m_currentPos | is the current origin point position or seed point position |
m_radius | is the radius of specific circle that covers the origin point |
m_randomMode | is the random mode that it will be on positive or negative side |
The following function is modified from :- Brian Reavis (2010). Diffuse Limited Aggregation Rendered with Sunflow [online]. [Accessed 07 July 2011]. Available from: <http://thirdroute.com/projects/dla/>
Definition at line 337 of file DLAStructure.cpp.
References m_sceneHeight, m_sceneWidth, m_windDir, m_windEnabled, m_windSpeed, and setDecimalValue().
{ // ----- adjust windDirection for particular origin point if(m_windEnabled==true) { ngl::Vector m_newOrigin = m_currentPos; ngl::Vector m_originAtCentre = ngl::Vector(0.0,0.0,0.0); float m_xDiff = m_newOrigin.m_x - m_originAtCentre.m_x; float m_zDiff = m_newOrigin.m_z - m_originAtCentre.m_z; ngl::Vector m_adaptedOrigin = m_windDir; m_currentPos = ngl::Vector(m_adaptedOrigin.m_x+m_xDiff, m_adaptedOrigin.m_y, m_adaptedOrigin.m_z+m_zDiff); float m_windXDiff = m_currentPos.m_x - m_newOrigin.m_x; float m_windZDiff = m_currentPos.m_z - m_newOrigin.m_z; float m_adjustWindXDiff = (m_windSpeed*m_windXDiff)/10; float m_adjustWindZDiff = (m_windSpeed*m_windZDiff)/10; m_currentPos = ngl::Vector(m_newOrigin.m_x+m_adjustWindXDiff, m_currentPos.m_y, m_newOrigin.m_z+m_adjustWindZDiff); if(m_currentPos.m_x>m_sceneWidth/10) m_currentPos.m_x = m_sceneWidth/10; else if(m_currentPos.m_x<-(m_sceneWidth/10)) m_currentPos.m_x = -(m_sceneWidth/10); if(m_currentPos.m_z>m_sceneHeight/10) m_currentPos.m_z = m_sceneHeight/10; else if(m_currentPos.m_z<-(m_sceneHeight/10)) m_currentPos.m_z = -(m_sceneHeight/10); } float m_calcX = m_currentPos.m_x; float m_calcZ = m_currentPos.m_z; float m_y = m_currentPos.m_y; // random floating number m_radius = m_radius*100; m_y = rand() % (int)m_radius; // z-negative side if(m_randomMode==-1) m_y = m_y - m_radius; m_radius = m_radius/100; m_y = m_y/100; float xyRadius = m_radius/2; float m_twoPi = 6.283185; m_twoPi = m_twoPi*1000000; float xyTheta = rand()%(int)m_twoPi; // TWO_PI xyTheta = xyTheta/1000000; m_calcX = cos(xyTheta)*xyRadius; m_calcZ = sin(xyTheta)*xyRadius; m_calcX = setDecimalValue(m_calcX, 2); m_calcZ = setDecimalValue(m_calcZ, 2); m_calcX += m_currentPos.m_x; m_calcZ += m_currentPos.m_z; m_y = 0.0; return ngl::Vector(m_calcX,m_y, m_calcZ); }
ngl::Vector DLAStructure::moveRandomPoint | ( | ngl::Vector | m_currentPoint, |
int | m_mode | ||
) |
This method will move the current random point to the new random position.
m_currentPoint | is the position of current random point |
m_mode | is the mode of moving direction that the point would randomly move |
Definition at line 877 of file DLAStructure.cpp.
References m_pointRadius.
{ if(m_mode==1) // ++x { m_currentPoint.m_x += m_pointRadius*8; } else if(m_mode==2) // --x { m_currentPoint.m_x -= m_pointRadius*8; } else if(m_mode==3) // ++y { m_currentPoint.m_y += m_pointRadius*8; } else if(m_mode==4) // --y { m_currentPoint.m_y -= m_pointRadius*8; } else if(m_mode==5) // ++z { m_currentPoint.m_z += m_pointRadius*8; } else // --z { m_currentPoint.m_z -= m_pointRadius*8; } return m_currentPoint; }
float DLAStructure::setDecimalValue | ( | float | m_number, |
int | m_decimalPlaces | ||
) |
This method will set the specific number to have the specific decimal places.
m_number | is the specific number that wish to be changed |
m_decimalPlaces | is the specific decimal places that wish to be applied to the number |
Definition at line 937 of file DLAStructure.cpp.
{ float m_decimalPlacesNumber = pow(10, m_decimalPlaces); float m_intNumber = m_number * m_decimalPlacesNumber; int m_roundedNumber = ceil(m_intNumber); float m_fixedNumber = m_roundedNumber/m_decimalPlacesNumber; return m_fixedNumber; }
bool DLAStructure::m_checkForm [private] |
the flag to check the building DLA structure with other built DLA structure
Definition at line 306 of file DLAStructure.h.
float DLAStructure::m_circleRadius [private] |
radius of circle for the random point area in dla progress
Definition at line 279 of file DLAStructure.h.
int DLAStructure::m_currentOriginIndex [private] |
the current index of origin
Definition at line 327 of file DLAStructure.h.
int DLAStructure::m_distanceForm [private] |
the appropriate distance of DLA point
Definition at line 331 of file DLAStructure.h.
std::vector<FuelPoint> DLAStructure::m_dlaLine [private] |
the list contians the seed point of each new dla points
Definition at line 266 of file DLAStructure.h.
std::vector<FuelPoint> DLAStructure::m_dlaList [private] |
the list contains the new dla points
Definition at line 270 of file DLAStructure.h.
float DLAStructure::m_dlaPointDistance [private] |
radius between dla point or the distance between each dla point
Definition at line 287 of file DLAStructure.h.
int DLAStructure::m_dlaSize [private] |
size of dla per origin point
Definition at line 291 of file DLAStructure.h.
std::vector<FuelObject> DLAStructure::m_objList [private] |
the list contains the fuel objects
Definition at line 274 of file DLAStructure.h.
ngl::Vector DLAStructure::m_originSeed [private] |
the origin point position
Definition at line 296 of file DLAStructure.h.
std::vector<FuelPoint> DLAStructure::m_otherOriginList [private] |
the list of origin point on the whold fire area
Definition at line 301 of file DLAStructure.h.
float DLAStructure::m_pointRadius [private] |
radius of the point
Definition at line 283 of file DLAStructure.h.
std::vector<FuelPoint> DLAStructure::m_previousDLAList [private] |
the list of point on previous DLA structure
Definition at line 323 of file DLAStructure.h.
int DLAStructure::m_sceneHeight [private] |
height size of fire area
Definition at line 257 of file DLAStructure.h.
std::vector<FuelPoint> DLAStructure::m_scenePointList [private] |
the list contains all points on the scene that are available to catch the fire
Definition at line 262 of file DLAStructure.h.
int DLAStructure::m_sceneWidth [private] |
width size of fire area
Definition at line 253 of file DLAStructure.h.
ngl::Vector DLAStructure::m_windDir [private] |
the wind direction
Definition at line 311 of file DLAStructure.h.
bool DLAStructure::m_windEnabled [private] |
the wind flag
Definition at line 319 of file DLAStructure.h.
int DLAStructure::m_windSpeed [private] |
the wind speed
Definition at line 315 of file DLAStructure.h.