14 using System.Collections.Generic;
30 return Math.Sqrt(Math.Pow(pointA[0]-pointB[0], 2) + Math.Pow(pointA[1]-pointB[1], 2));
37 return Math.Sqrt(Math.Pow(pointA[0]-pointB[0], 2) + Math.Pow(pointA[1]-pointB[1], 2));
42 public static double Distance3f(
float[] pointA,
float[] pointB)
44 return Math.Sqrt(Math.Pow(pointA[0]-pointB[0], 2) + Math.Pow(pointA[1]-pointB[1], 2) + Math.Pow(pointA[2]-pointB[2], 2));
51 List<float[]> neighbor_coords =
new List<float[]>();
52 ArrayList neighbor_theta_phi =
new ArrayList();
53 ArrayList neighbor_theta_phi_plus10 =
new ArrayList();
54 ArrayList neighbor_theta_phi_plus20 =
new ArrayList();
55 float min_theta = 1000.0f;
56 float max_theta = 0.0f;
57 float min_phi = 1000.0f;
65 if (dist < radius + 20 && dist > 2.0)
68 float[] atom =
new float[3];
72 float theta = (float) Math.Acos(atom[2] / dist);
73 float phi = (float) Math.Atan2(atom[1], atom[0]);
77 neighbor_theta_phi_plus20.
Add(theta_phi);
80 if(theta + (
float) Math.PI < 1.5f * Math.PI && phi + (
float) Math.PI * 2.0f < 2.0f * Math.PI)
83 theta_phi[0] = theta + (float) Math.PI;
84 theta_phi[1] = phi + (
float) Math.PI * 2.0f;
85 neighbor_theta_phi_plus20.
Add(theta_phi);
89 if(theta + (
float) Math.PI < 1.5f * Math.PI)
92 theta_phi[0] = theta + (float) Math.PI;
94 neighbor_theta_phi_plus20.
Add(theta_phi);
95 if (theta + (
float) Math.PI > max_theta)
96 max_theta = theta + (float) Math.PI;
100 if( phi + (
float) Math.PI * 2.0f < 2.0f * Math.PI)
102 theta_phi =
new Vector(2);
103 theta_phi[0] = theta;
104 theta_phi[1] = phi + (float) Math.PI * 2.0f;
105 neighbor_theta_phi_plus20.
Add(theta_phi);
106 if (phi + (
float) Math.PI * 2.0f > max_phi)
107 max_phi = phi + (float) Math.PI * 2.0f;
111 if (theta < min_theta)
115 if (dist < radius + 10)
117 for(
int j=1; j<=added; j++){
118 neighbor_theta_phi_plus10.Add(neighbor_theta_phi_plus20[neighbor_theta_phi_plus20.Count-j]);
126 for(
int j=1; j<=added; j++){
127 neighbor_theta_phi.Add(neighbor_theta_phi_plus20[neighbor_theta_phi_plus20.Count-j]);
166 Debug.Log(
"Nb of neighbors: "+neighbor_theta_phi.Count);
167 Debug.Log(
"Min/max theta/phi: "+min_theta+
" "+max_theta+
" "+min_phi+
" "+max_phi);
177 foreach (
Vector vert
in result.Vertizes)
179 if (vert[0] > min_theta && vert[0] < max_theta && vert[1] < max_phi && vert[1] > min_phi)
187 result.Vertizes = temp;
189 double max_dist = 0.0;
190 float[] best_pos =
new float[2];
192 double distance = 0.0;
193 Dictionary<double, float[]> vertices =
new Dictionary<double, float[]>();
204 float[] t =
new float[2];
207 vertices[distance] = t;
208 if (distance > max_dist)
211 best_pos[0] = (float) edge.
VVertexA[0];
212 best_pos[1] = (
float) edge.
VVertexA[1];
219 float[] t =
new float[2];
222 vertices[distance] = t;
223 if (distance > max_dist)
226 best_pos[0] = (float) edge.
VVertexB[0];
227 best_pos[1] = (
float) edge.
VVertexB[1];
237 Debug.Log (result.Vertizes.Count);
239 double max_dist_plus10 = 0.0f;
240 float[] best_pos_plus10 =
new float[2];
253 float[] t =
new float[2];
257 if (distance > max_dist_plus10)
259 max_dist_plus10 = distance;
260 best_pos_plus10[0] = (float) edge.
VVertexA[0];
261 best_pos_plus10[1] = (
float) edge.
VVertexA[1];
271 float[] t =
new float[2];
275 if (distance > max_dist_plus10)
277 max_dist_plus10 = distance;
278 best_pos_plus10[0] = (float) edge.
VVertexB[0];
279 best_pos_plus10[1] = (
float) edge.
VVertexB[1];
290 Debug.Log (result.Vertizes.Count);
292 double max_dist_plus20 = 0.0f;
293 float[] best_pos_plus20 =
new float[2];
306 float[] t =
new float[2];
310 if (distance > max_dist_plus20)
312 max_dist_plus20 = distance;
313 best_pos_plus20[0] = (float) edge.
VVertexA[0];
314 best_pos_plus20[1] = (
float) edge.
VVertexA[1];
324 float[] t =
new float[2];
328 if (distance > max_dist_plus20)
330 max_dist_plus20 = distance;
331 best_pos_plus20[0] = (float) edge.
VVertexB[0];
332 best_pos_plus20[1] = (
float) edge.
VVertexB[1];
338 var list = vertices.Keys.ToList();
340 float[] cartesian =
new float[3];
341 Debug.Log(
"4 best positions");
345 int nb = list.Count -1;
350 Debug.Log(
"count: "+count+
"\t nb: "+nb);
353 cartesian[0] = (radius * (float) Math.Sin(vertices[list[nb]][0]) * (float) Math.Cos(vertices[list[nb]][1])) + target[0];
354 cartesian[1] = (radius * (float) Math.Sin(vertices[list[nb]][0]) * (float) Math.Sin(vertices[list[nb]][1])) + target[1];
355 cartesian[2] = (radius * (float) Math.Cos(vertices[list[nb]][0])) + target[2];
358 for(
int k =0; k<(4-count); k++){
370 Debug.Log (
"Best pov number "+(count)+
" : "+vertices[list[nb]][0]+
" "+vertices[list[nb]][1]+
"\tDistance: "+list[nb]);
379 Debug.Log (
"Best pov number "+(count)+
" : "+vertices[list[nb]][0]+
" "+vertices[list[nb]][1]+
"\tDistance: "+list[nb]);
416 Debug.Log (
"Maximum distance: "+max_dist+
" "+max_dist_plus10+
" "+max_dist_plus20);
417 Debug.Log(
"Theta and phi: "+best_pos[0]+
" "+best_pos[1]);
418 Debug.Log(
"Theta and phi at 10: "+best_pos_plus10[0]+
" "+best_pos_plus10[1]);
419 Debug.Log(
"Theta and phi at 20: "+best_pos_plus20[0]+
" "+best_pos_plus20[1]);
430 GameObject camera = GameObject.Find(
"LoadBox");
static Vector3 optim_user_cam_pos
3D coordinates of the selected best camera position.
static VoronoiGraph ComputeVoronoiGraph(IEnumerable Datapoints)
A vector class, implementing all interesting features of vectors
void Add(Vector V)
Add another vector
static Vector3 optim_target
3D coordinates of the target.
static void GetOptimalPosition(float[] target, float radius)
Get the position with the largest view cone on a specific target and with respect to an input radius ...
Summary description for Hashset.
static double Distance3f(float[] pointA, float[] pointB)
Calculate distance between two float array of length 3.
!WiP Includes FLAGS of GUI.
The GNParameters class regroups settings used for Guided Navigation and GLIC spreading.
static double Distance2f(Vector pointA, Vector pointB)
Calculate distance between two vectors of length 2.
static Vector3[] optim_cam_position
3D coordinates of the 4 best camera positions.
static Vector3 optim_view_start_point
static double Distance2f(Vector pointA, float[] pointB)
Calculate distance between an array and a vector of length 2.
static List< float[]> atomsLocationlist
The coordinates of each atom.