Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hurstel
CGoGN
Commits
3f25bf9d
Commit
3f25bf9d
authored
Jan 27, 2011
by
Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify the social agents environments
parent
48b7797e
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
206 additions
and
63 deletions
+206
-63
Apps/Examples/SocialAgents/include/agent.h
Apps/Examples/SocialAgents/include/agent.h
+0
-1
Apps/Examples/SocialAgents/include/env_generator.h
Apps/Examples/SocialAgents/include/env_generator.h
+3
-0
Apps/Examples/SocialAgents/include/env_generator.hpp
Apps/Examples/SocialAgents/include/env_generator.hpp
+114
-0
Apps/Examples/SocialAgents/include/simulator.h
Apps/Examples/SocialAgents/include/simulator.h
+2
-0
Apps/Examples/SocialAgents/src/agent.cpp
Apps/Examples/SocialAgents/src/agent.cpp
+4
-4
Apps/Examples/SocialAgents/src/env_map.cpp
Apps/Examples/SocialAgents/src/env_map.cpp
+3
-5
Apps/Examples/SocialAgents/src/simulator.cpp
Apps/Examples/SocialAgents/src/simulator.cpp
+46
-6
Apps/Examples/SocialAgents/src/viewer.cpp
Apps/Examples/SocialAgents/src/viewer.cpp
+22
-36
include/Algo/Modelisation/polyhedron.h
include/Algo/Modelisation/polyhedron.h
+1
-1
include/Algo/Modelisation/polyhedron.hpp
include/Algo/Modelisation/polyhedron.hpp
+9
-9
include/Geometry/orientation.hpp
include/Geometry/orientation.hpp
+2
-1
No files found.
Apps/Examples/SocialAgents/include/agent.h
View file @
3f25bf9d
...
...
@@ -65,7 +65,6 @@ class Simulator;
// std::vector<Dart> includingFaces;
CGoGN
::
Algo
::
MovingObjects
::
ParticleCell2D
<
PFP
>
*
part
;
float
rangeSq
;
bool
newCells
;
bool
treated
;
};
...
...
Apps/Examples/SocialAgents/include/env_generator.h
View file @
3f25bf9d
...
...
@@ -10,6 +10,9 @@ namespace CityGenerator
template
<
typename
PFP
>
void
generateAbsolutSpiralOfDeath
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
DartMarker
&
closeMark
,
unsigned
int
side
,
float
rMin
,
float
rMax
,
float
nbTurns
);
template
<
typename
PFP
>
void
generateToboggan
(
typename
PFP
::
MAP
&
map
,
typename
PFP
::
TVEC3
&
position
,
DartMarker
&
closeMark
,
unsigned
int
side
,
float
rMin
,
float
rMax
,
float
nbTurns
);
template
<
typename
PFP
,
typename
EMBV
>
void
generateSmallCity
(
typename
PFP
::
MAP
&
map
,
EMBV
&
position
,
DartMarker
&
closeMark
,
float
sideSize
);
...
...
Apps/Examples/SocialAgents/include/env_generator.hpp
View file @
3f25bf9d
...
...
@@ -27,6 +27,120 @@ void generateAbsolutSpiralOfDeath(typename PFP::MAP& map,typename PFP::TVEC3& po
map.initOrbitEmbedding(FACE_ORBIT);
}
template <typename PFP>
void generateToboggan(typename PFP::MAP& map,typename PFP::TVEC3& position, DartMarker& closeMark, unsigned int side, float rMin, float rMax,float nbTurns)
{
//the stairs
Algo::Modelisation::Polyhedron<PFP> prim(map,position);
prim.grid_topo(side,3);
//the slide
Algo::Modelisation::Polyhedron<PFP> prim2(map,position);
prim2.grid_topo(side/4,3);
float height=150;
prim2.embedHelicoid(rMin*4,rMax,-1*height,0.5f,-1);
// typename PFP::VEC3 transl(0,2*rMax,height);
typename PFP::VEC3 transl(-rMax/2,0,height);
CellMarker m(map, VERTEX_CELL) ;
for(Dart d=map.begin();d!=map.end();map.next(d)) {
if(!m.isMarked(d)) {
m.mark(d);
position[d] += transl;
position[d][0] *= 2.0f;
}
}
prim.embedHelicoid(rMin,rMax,height,nbTurns-0.5f);
Dart dStairsDown = map.phi_1(prim.getDart());
Dart dStairsUp = dStairsDown;
do {
closeMark.markOrbit(FACE_ORBIT,dStairsUp);
closeMark.markOrbit(FACE_ORBIT,map.phi2(map.phi1(map.phi1(map.phi2(map.phi_1(dStairsUp))))));
dStairsUp= map.phi2(map.phi1(map.phi1(dStairsUp)));
} while(map.phi2(dStairsUp)!=dStairsUp);
Dart dSlideUp = map.phi_1(prim2.getDart());
Dart dSlideDown = dSlideUp;
do {
closeMark.markOrbit(FACE_ORBIT,dSlideDown);
closeMark.markOrbit(FACE_ORBIT,map.phi2(map.phi1(map.phi1(map.phi2(map.phi_1(dSlideDown))))));
dSlideDown= map.phi2(map.phi1(map.phi1(dSlideDown)));
} while(map.phi2(dSlideDown)!=dSlideDown);
Algo::Modelisation::Polyhedron<PFP> primPathUp(map,position);
primPathUp.grid_topo(1,3);
Dart dPathUp = map.phi_1(primPathUp.getDart());
Algo::Modelisation::Polyhedron<PFP> primPathDown(map,position);
primPathDown.grid_topo(1,3);
Dart dPathDown = map.phi_1(primPathDown.getDart());
closeMark.markOrbit(FACE_ORBIT,dPathUp);
closeMark.markOrbit(FACE_ORBIT,dPathDown);
map.sewFaces(dStairsUp,dPathUp);
map.sewFaces(dSlideUp,map.phi1(map.phi1(dPathUp)));
map.sewFaces(dSlideDown,dPathDown);
map.sewFaces(dStairsDown,map.phi1(map.phi1(dPathDown)));
dPathUp = map.phi_1(map.alpha1(dPathUp));
dPathDown = map.phi_1(map.alpha1(dPathDown));
dSlideUp = map.phi_1(map.alpha1(dSlideUp));
dSlideDown =map.alpha_1(map.phi1(dSlideDown));
dStairsUp = map.alpha_1(map.phi1(dStairsUp));
dStairsDown = map.phi_1(map.alpha1(dStairsDown));
// Dart dPathUp = map.newOrientedFace(4);
// Dart dPathDown = map.newOrientedFace(4);
map.sewFaces(dStairsUp,dPathUp);
map.sewFaces(dSlideUp,map.phi1(map.phi1(dPathUp)));
map.sewFaces(dSlideDown,dPathDown);
map.sewFaces(dStairsDown,map.phi1(map.phi1(dPathDown)));
dPathUp = map.phi_1(map.alpha1(dPathUp));
dPathDown = map.phi_1(map.alpha1(dPathDown));
dSlideUp = map.phi_1(map.alpha1(dSlideUp));
dStairsUp = map.alpha_1(map.phi1(dStairsUp));
dSlideDown =map.alpha_1(map.phi1(dSlideDown));
dStairsDown = map.phi_1(map.alpha1(dStairsDown));
closeMark.markOrbit(FACE_ORBIT,dPathUp);
closeMark.markOrbit(FACE_ORBIT,dPathDown);
map.sewFaces(dStairsUp,dPathUp);
map.sewFaces(dSlideUp,map.phi1(map.phi1(dPathUp)));
map.sewFaces(dSlideDown,dPathDown);
map.sewFaces(dStairsDown,map.phi1(map.phi1(dPathDown)));
// map.sewFaces(dStairsDown,dPathDown);
// map.sewFaces(dSlideDown,map.phi1(map.phi1(dPathDown)));
// map.sewFaces(dStairs,dSlide);
map.closeMap(closeMark) ;
CellMarker traite(map,FACE_CELL);
for(Dart d = map.begin(); d!=map.end() ; map.next(d)) {
if(!traite.isMarked(d)) {
traite.mark(d);
map.splitFace(d,map.phi1(map.phi1(d)));
}
}
for(Dart d = map.begin(); d!=map.end() ; map.next(d)) {
if(closeMark.isMarked(d)) {
closeMark.markOrbit(FACE_ORBIT,d);
}
}
map.initOrbitEmbedding(FACE_ORBIT);
}
template <typename PFP, typename EMBV>
void generateSmallCity(typename PFP::MAP& map, EMBV& position, DartMarker& closeMark, float sideSize)
{
...
...
Apps/Examples/SocialAgents/include/simulator.h
View file @
3f25bf9d
...
...
@@ -53,6 +53,8 @@ class Simulator
std
::
vector
<
PFP
::
VEC3
>
socialAgents
;
void
setPreferredNextCellVelocities
();
// std::vector<Dart> path;
/** Added function */
...
...
Apps/Examples/SocialAgents/src/agent.cpp
View file @
3f25bf9d
#include "agent.h"
#include "simulator.h"
Agent
::
Agent
(
Simulator
*
sim
,
size_t
agentNo
)
:
agentNeighbors_
(),
maxNeighbors_
(
0
),
maxSpeed_
(
0.0
f
),
neighborDist_
(
0.0
f
),
newVelocity_
(),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(),
prefVelocity_
(),
radius_
(
0.0
f
),
sim_
(
sim
),
timeHorizon_
(
0.0
f
),
timeHorizonObst_
(
0.0
f
),
velocity_
(),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
newCells
(
false
),
treated
(
false
)
Agent
::
Agent
(
Simulator
*
sim
,
size_t
agentNo
)
:
agentNeighbors_
(),
maxNeighbors_
(
0
),
maxSpeed_
(
0.0
f
),
neighborDist_
(
0.0
f
),
newVelocity_
(),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(),
prefVelocity_
(),
radius_
(
0.0
f
),
sim_
(
sim
),
timeHorizon_
(
0.0
f
),
timeHorizonObst_
(
0.0
f
),
velocity_
(),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
treated
(
false
)
{
rangeSq
=
sqr
(
timeHorizonObst_
*
maxSpeed_
+
radius_
);
}
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC_A
&
position
,
size_t
agentNo
)
:
agentNeighbors_
(),
maxNeighbors_
(
sim
->
defaultAgent_
->
maxNeighbors_
),
maxSpeed_
(
sim
->
defaultAgent_
->
maxSpeed_
),
neighborDist_
(
sim
->
defaultAgent_
->
neighborDist_
),
newVelocity_
(
sim
->
defaultAgent_
->
velocity_
),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(
position
),
prefVelocity_
(),
radius_
(
sim
->
defaultAgent_
->
radius_
),
sim_
(
sim
),
timeHorizon_
(
sim
->
defaultAgent_
->
timeHorizon_
),
timeHorizonObst_
(
sim
->
defaultAgent_
->
timeHorizonObst_
),
velocity_
(
sim
->
defaultAgent_
->
velocity_
),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
newCells
(
false
),
treated
(
false
)
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC_A
&
position
,
size_t
agentNo
)
:
agentNeighbors_
(),
maxNeighbors_
(
sim
->
defaultAgent_
->
maxNeighbors_
),
maxSpeed_
(
sim
->
defaultAgent_
->
maxSpeed_
),
neighborDist_
(
sim
->
defaultAgent_
->
neighborDist_
),
newVelocity_
(
sim
->
defaultAgent_
->
velocity_
),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(
position
),
prefVelocity_
(),
radius_
(
sim
->
defaultAgent_
->
radius_
),
sim_
(
sim
),
timeHorizon_
(
sim
->
defaultAgent_
->
timeHorizon_
),
timeHorizonObst_
(
sim
->
defaultAgent_
->
timeHorizonObst_
),
velocity_
(
sim
->
defaultAgent_
->
velocity_
),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
treated
(
false
)
{
nearestDart
=
sim
->
envMap
.
getBelongingCell
(
VEC3
(
position
[
0
],
position
[
1
],
0
));
part
=
new
Algo
::
MovingObjects
::
ParticleCell2D
<
PFP
>
(
sim
->
envMap
.
map
,
nearestDart
,
position
,
sim
->
envMap
.
position
,
sim
->
envMap
.
closeMark
);
rangeSq
=
sqr
(
timeHorizonObst_
*
maxSpeed_
+
radius_
);
}
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC_A
&
position
,
size_t
agentNo
,
Dart
d
)
:
agentNeighbors_
(),
maxNeighbors_
(
sim
->
defaultAgent_
->
maxNeighbors_
),
maxSpeed_
(
sim
->
defaultAgent_
->
maxSpeed_
),
neighborDist_
(
sim
->
defaultAgent_
->
neighborDist_
),
newVelocity_
(
sim
->
defaultAgent_
->
velocity_
),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(
position
),
prefVelocity_
(),
radius_
(
sim
->
defaultAgent_
->
radius_
),
sim_
(
sim
),
timeHorizon_
(
sim
->
defaultAgent_
->
timeHorizon_
),
timeHorizonObst_
(
sim
->
defaultAgent_
->
timeHorizonObst_
),
velocity_
(
sim
->
defaultAgent_
->
velocity_
),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
newCells
(
false
),
treated
(
false
)
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC_A
&
position
,
size_t
agentNo
,
Dart
d
)
:
agentNeighbors_
(),
maxNeighbors_
(
sim
->
defaultAgent_
->
maxNeighbors_
),
maxSpeed_
(
sim
->
defaultAgent_
->
maxSpeed_
),
neighborDist_
(
sim
->
defaultAgent_
->
neighborDist_
),
newVelocity_
(
sim
->
defaultAgent_
->
velocity_
),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(
position
),
prefVelocity_
(),
radius_
(
sim
->
defaultAgent_
->
radius_
),
sim_
(
sim
),
timeHorizon_
(
sim
->
defaultAgent_
->
timeHorizon_
),
timeHorizonObst_
(
sim
->
defaultAgent_
->
timeHorizonObst_
),
velocity_
(
sim
->
defaultAgent_
->
velocity_
),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
treated
(
false
)
{
nearestDart
=
d
;
part
=
new
Algo
::
MovingObjects
::
ParticleCell2D
<
PFP
>
(
sim
->
envMap
.
map
,
nearestDart
,
position
,
sim
->
envMap
.
position
,
sim
->
envMap
.
closeMark
);
rangeSq
=
sqr
(
timeHorizonObst_
*
maxSpeed_
+
radius_
);
}
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC_A
&
position
,
float
neighborDist
,
size_t
maxNeighbors
,
float
timeHorizon
,
float
timeHorizonObst
,
float
radius
,
const
VEC_A
&
velocity
,
float
maxSpeed
,
size_t
agentNo
)
:
agentNeighbors_
(),
maxNeighbors_
(
maxNeighbors
),
maxSpeed_
(
maxSpeed
),
neighborDist_
(
neighborDist
),
newVelocity_
(
velocity
),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(
position
),
prefVelocity_
(),
radius_
(
radius
),
sim_
(
sim
),
timeHorizon_
(
timeHorizon
),
timeHorizonObst_
(
timeHorizonObst
),
velocity_
(
velocity
),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
newCells
(
false
),
treated
(
false
)
Agent
::
Agent
(
Simulator
*
sim
,
const
VEC_A
&
position
,
float
neighborDist
,
size_t
maxNeighbors
,
float
timeHorizon
,
float
timeHorizonObst
,
float
radius
,
const
VEC_A
&
velocity
,
float
maxSpeed
,
size_t
agentNo
)
:
agentNeighbors_
(),
maxNeighbors_
(
maxNeighbors
),
maxSpeed_
(
maxSpeed
),
neighborDist_
(
neighborDist
),
newVelocity_
(
velocity
),
obstacleNeighbors_
(),
orcaLines_
(),
position_
(
position
),
prefVelocity_
(),
radius_
(
radius
),
sim_
(
sim
),
timeHorizon_
(
timeHorizon
),
timeHorizonObst_
(
timeHorizonObst
),
velocity_
(
velocity
),
agentNo_
(
agentNo
),
goalNo_
(
agentNo
),
treated
(
false
)
{
nearestDart
=
sim
->
envMap
.
getBelongingCell
(
VEC3
(
position
[
0
],
position
[
1
],
0
));
part
=
new
Algo
::
MovingObjects
::
ParticleCell2D
<
PFP
>
(
sim
->
envMap
.
map
,
nearestDart
,
position
,
sim
->
envMap
.
position
,
sim
->
envMap
.
closeMark
);
...
...
Apps/Examples/SocialAgents/src/env_map.cpp
View file @
3f25bf9d
...
...
@@ -99,7 +99,6 @@ bool EnvMap::simplifyVertex(Dart& d)
if (d1==dd) // last edge is pending edge inside of face
finished=true;
map.deleteFace(dd);
// map.deleteOrientedFace(dd);
dd = d1;
} while (!finished);
...
...
@@ -223,7 +222,7 @@ void EnvMap::insertObstacleOfFace(PFP::AGENTS agents,const Dart d)
do {
if(closeMark.isMarked(dd) /*&& (position[map.phi2(dd)][2]==0.0 || position[map.phi1(map.phi2(dd))][2] ==0.0f)*/) {
for(PFP::AGENTS::iterator it=agents.begin(); it!= agents.end(); ++it) {
// if(leftOf((*it)->part->m_position,position[
map.phi2(dd)],position[map.phi1(map.phi2(dd)
)])<0.0f) {
// if(leftOf((*it)->part->m_position,position[
dd],position[map.phi1(dd
)])<0.0f) {
(*it)->insertObstacleNeighbor(dd);
// }
}
...
...
@@ -340,8 +339,8 @@ void EnvMap::addNeighborAgents(PFP::AGENTS agentsFrom,PFP::AGENTS agentsTo)
void EnvMap::updateMap()
{
// simplifyFaces();
subdivideFaces
()
;
map
.
setCurrentLevel
(
map
.
getMaxLevel
())
;
//
subdivideFaces() ;
//
map.setCurrentLevel(map.getMaxLevel()) ;
}
void EnvMap::subdivideFaces()
...
...
@@ -637,7 +636,6 @@ void EnvMap::resetAgentInFace(Agent * agent)
agent->part->state = FACE_ORBIT;
agent->part->move(agent->position_) ;
// agent->part->d = d;
agent
->
newCells
=
true
;
}
void EnvMap::addObstacle(std::vector<VEC3> points)
...
...
Apps/Examples/SocialAgents/src/simulator.cpp
View file @
3f25bf9d
...
...
@@ -14,17 +14,18 @@ Simulator::Simulator() : agents_(), defaultAgent_(0), globalTime_(0.0f), timeSte
// CGoGN::CityGenerator::generateGrid<PFP,PFP::TVEC3>(envMap.map,envMap.position,100,100,50.0f,envMap.closeMark);
envMap
.
sideSize
=
70.0
f
;
CGoGN
::
CityGenerator
::
generateSmallCity
<
PFP
,
PFP
::
TVEC3
>
(
envMap
.
map
,
envMap
.
position
,
envMap
.
closeMark
,
envMap
.
sideSize
);
//
CGoGN::CityGenerator::generateSmallCity<PFP,PFP::TVEC3>(envMap.map,envMap.position,envMap.closeMark,envMap.sideSize);
// CGoGN::CityGenerator::generateAbsolutSpiralOfDeath<PFP>(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100);
// CGoGN::CityGenerator::generateAbsolutSpiralOfDeath<PFP>(envMap.map,envMap.position,envMap.closeMark,2000,0.25,110,100);
CGoGN
::
CityGenerator
::
generateToboggan
<
PFP
>
(
envMap
.
map
,
envMap
.
position
,
envMap
.
closeMark
,
100
,
0.25
,
200
,
10
);
// std::cout << "simplify" << std::endl;
// envMap.simplify();
envMap
.
map
.
init
();
//
envMap.map.init();
std
::
cout
<<
"setup scenario"
<<
std
::
endl
;
//
setupHelicoidScenario(1,50
);
setup
Scenario
(
);
//
setupScenario(
);
setup
HelicoidScenario
(
1
,
50
);
// Dart dStop=envMap.map.begin();
// for(unsigned int i=0;i<5000;++i) envMap.map.next(dStop);
...
...
@@ -190,6 +191,45 @@ void Simulator::setPreferredVelocities(PFP::VEC3 posToReach)
}
}
void
Simulator
::
setPreferredNextCellVelocities
()
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
agents_
.
size
());
++
i
)
{
Dart
dNext
=
agents_
[
i
]
->
part
->
d
;
while
(
envMap
.
closeMark
.
isMarked
(
envMap
.
map
.
phi2
(
dNext
))
&&
envMap
.
map
.
phi1
(
dNext
)
!=
agents_
[
i
]
->
part
->
d
)
dNext
=
envMap
.
map
.
phi1
(
dNext
);
VEC3
goalVector
;
if
(
envMap
.
closeMark
.
isMarked
(
envMap
.
map
.
phi2
(
dNext
)))
{
goalVector
=
VEC3
(
0
,
0
,
0
);
}
else
{
// goalVector = Algo::Geometry::faceCentroid<PFP>(envMap.map,envMap.map.phi2(dNext),envMap.position);
goalVector
=
(
envMap
.
position
[
dNext
]
+
envMap
.
position
[
envMap
.
map
.
phi2
(
dNext
)])
*
0.5
f
;
goalVector
-=
agents_
[
i
]
->
position_
;
goalVector
=
normalize
(
goalVector
);
}
// goalVector *= 0.5f;
// goalVector += agents_[i]->prefVelocity_;
// goalVector *= 0.5f;
// if (absSq(goalVector) > 1.0f) {
// goalVector = normalize(goalVector);
// }
this
->
setAgentPrefVelocity
(
i
,
goalVector
);
/*
* Perturb a little to avoid deadlocks due to perfect symmetry.
*/
float
angle
=
std
::
rand
()
*
2.0
f
*
M_PI
/
RAND_MAX
;
float
dist
=
std
::
rand
()
*
0.0001
f
/
RAND_MAX
;
this
->
setAgentPrefVelocity
(
i
,
this
->
getAgentPrefVelocity
(
i
)
+
VEC3
(
dist
*
std
::
cos
(
angle
),
dist
*
std
::
sin
(
angle
),
0.0
f
));
}
}
void
Simulator
::
setPreferredPathVelocities
()
{
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
agents_
.
size
());
++
i
)
{
...
...
@@ -307,7 +347,7 @@ void Simulator::setupHelicoidScenario(float rMax,float rMin)
DartMarkerStore
filled
(
envMap
.
map
);
bool
found
=
false
;
int
nbPack
=
3
000
;
int
nbPack
=
2
000
;
for
(
int
i
=
0
;
i
<
nbPack
&&
d
!=
envMap
.
map
.
end
();
++
i
)
{
found
=
false
;
...
...
Apps/Examples/SocialAgents/src/viewer.cpp
View file @
3f25bf9d
...
...
@@ -165,20 +165,29 @@ void MyGlutWin::myRedraw()
glColor3f
(
1.0
f
,
0.0
f
,
0.0
f
);
std
::
vector
<
PFP
::
VEC3
>
v
=
sim
->
getAgentsPosition
();
// glLineWidth(10.0f);
// glPointSize(10.0f);
// glBegin(GL_POINTS);
// // for(std::vector<PFP::VEC3>::iterator it = v.begin() ; it != v.end(); ++it) {
// for(unsigned int i = 0.0f; i< v.size() ; ++i) {
// glColor3f(i%int(2.0f/3.0f*v.size())/(v.size()/3.0f),i%int(1.0f/3.0f*v.size())/(v.size()/3.0f),i/(v.size()/3.0f));
// glVertex3fv(&(v[i])[0]);
// glVertex3fv(&posToReach[0]);
// for(Dart d = sim->envMap.map.begin() ; d != sim->envMap.map.end() ; sim->envMap.map.next(d))
// glVertex3fv(&sim->envMap.getPosition(d)[0]);
// glEnd();
// glBegin(GL_LINES);
// for(std::vector<Dart>::iterator it = sim->path.begin() ; it != sim->path.end() ; ++ it) {
// VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim->envMap.map,*it,sim->envMap.position);
// glVertex3fv(&c[0]);
// }
// glEnd();
// glPointSize(10.0f);
// glBegin(GL_POINTS);
for
(
unsigned
int
i
=
0.0
f
;
i
<
v
.
size
()
;
++
i
)
{
// glBegin(GL_POINTS);
// for(unsigned int i = 0; i<4;++i) {
// for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
// glVertex3fv(&(*it)[0]);
// }
// }
// glEnd();
unsigned
int
i
=
0
;
for
(
std
::
vector
<
Agent
*
>::
iterator
it
=
sim
->
agents_
.
begin
()
;
it
!=
sim
->
agents_
.
end
()
;
++
it
,
++
i
)
{
// glColor3f(i%int(2.0f/3.0f*v.size())/(v.size()/3.0f),i%int(1.0f/3.0f*v.size())/(v.size()/3.0f),i/(v.size()/3.0f));
// glCircle3i(v[i][0],v[i][1],1.5f);
glPushMatrix
();
...
...
@@ -205,34 +214,10 @@ void MyGlutWin::myRedraw()
// glVertex3f(posR[0],posR[1],posR[2]);
glCircle3i
(
0
,
0
,
sim
->
agents_
[
i
]
->
radius_
);
glPopMatrix
();
}
// glEnd();
glColor3f
(
1.0
f
,
1.0
f
,
1.0
f
);
// glBegin(GL_POINTS);
// glVertex3fv(&posToReach[0]);
// for(Dart d = sim->envMap.map.begin() ; d != sim->envMap.map.end() ; sim->envMap.map.next(d))
// glVertex3fv(&sim->envMap.getPosition(d)[0]);
// glEnd();
// glBegin(GL_LINES);
// for(std::vector<Dart>::iterator it = sim->path.begin() ; it != sim->path.end() ; ++ it) {
// VEC3 c = Algo::Geometry::faceCentroid<PFP>(sim->envMap.map,*it,sim->envMap.position);
// glVertex3fv(&c[0]);
// }
// glEnd();
// glBegin(GL_POINTS);
// for(unsigned int i = 0; i<4;++i) {
// for(std::vector<VEC3>::iterator it=(*sim->pathToFollow[0]).begin() ; it!=(*sim->pathToFollow[0]).end() ; ++it) {
// glVertex3fv(&(*it)[0]);
// }
// }
// glEnd();
unsigned
int
i
=
0
;
for
(
std
::
vector
<
Agent
*
>::
iterator
it
=
sim
->
agents_
.
begin
()
;
it
!=
sim
->
agents_
.
end
()
;
++
it
,
++
i
)
{
// //draw all containing faces
// glColor3f(1,1,0);
// for(std::vector<Dart>::iterator incF = (*it)->includingFaces.begin(); incF != (*it)->includingFaces.end(); ++incF) {
...
...
@@ -256,7 +241,7 @@ void MyGlutWin::myRedraw()
// //and prediction triangle
glColor3f
(((
*
it
)
->
part
->
state
)
/
3.0
f
,((
*
it
)
->
part
->
state
%
2
),
0
);
glLineWidth
(
5.0
f
);
renderPredictionTriangle
(
sim
->
envMap
,(
*
it
)
->
part
->
d
,
(
*
it
)
->
part
->
m_position
);
renderPredictionTriangle
(
sim
->
envMap
,(
*
it
)
->
part
->
d
,
/*(*it)->part->m_position*/
posR
);
glLineWidth
(
1.0
f
);
//draw next goal
...
...
@@ -403,8 +388,9 @@ void MyGlutWin::animate(void)
// std::cout << "pos to reach : " << posToReach << std::endl;
// std::cout << sim->getGlobalTime() << " " << std::endl;
updateVisualization
(
sim
);
sim
->
setPreferredVelocities
(
posToReach
);
//
sim->setPreferredVelocities(posToReach);
// sim->setPreferredPathVelocities();
sim
->
setPreferredNextCellVelocities
();
sim
->
doStep
();
// sim->envMap.simplify();
glutPostRedisplay
();
...
...
include/Algo/Modelisation/polyhedron.h
View file @
3f25bf9d
...
...
@@ -295,7 +295,7 @@ public:
* @param maxHeight height to reach
* @param turns number of turn
*/
void
embedHelicoid
(
float
radius_min
,
float
radius_max
,
float
maxHeight
,
float
nbTurn
);
void
embedHelicoid
(
float
radius_min
,
float
radius_max
,
float
maxHeight
,
float
nbTurn
,
int
orient
=
1
);
/**
* transform the Polyhedron with transformation matrice
...
...
include/Algo/Modelisation/polyhedron.hpp
View file @
3f25bf9d
...
...
@@ -1017,7 +1017,7 @@ void Polyhedron<PFP>::embedTwistedStrip( float radius_min, float radius_max, fl
}
template <typename PFP>
void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn)
void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn
, int orient
)
{
typedef typename PFP::VEC3 VEC3 ;
...
...
@@ -1033,14 +1033,14 @@ void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float
{
// float r = radius_max + radius_min*cos(beta*float(j));
float r,x,y;
if(i==1) {
r = radius_max;
}
else {
r= radius_min;
}
x = r*sin(alpha*float(j));
y = r*cos(alpha*float(j));
//
if(i==1) {
//
r = radius_max;
//
}
//
else {
r= radius_min
+(radius_max-radius_min)*float(i)/float(m_ny)
;
//
}
x =
orient*
r*sin(alpha*float(j));
y =
orient*
r*cos(alpha*float(j));
VEC3 pos(x, y, j*hS);
Dart d = m_tableVertDarts[i*(m_nx+1)+j];
...
...
include/Geometry/orientation.hpp
View file @
3f25bf9d
...
...
@@ -35,7 +35,8 @@ Orientation2D testOrientation2D(const VEC3& P, const VEC3& Pa, const VEC3& Pb)
{
typedef
typename
VEC3
::
DATA_TYPE
T
;
const
T
min
=
std
::
numeric_limits
<
T
>::
min
()
*
T
(
100
);
// const T min = std::numeric_limits<T>::min()*T(100);
const
T
min
=
0.00001
;
T
wsof
=
(
Pa
[
0
]
-
P
[
0
])
*
(
P
[
1
]
-
Pb
[
1
])
-
(
P
[
0
]
-
Pb
[
0
])
*
(
Pa
[
1
]
-
P
[
1
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment