Tests: Updated results

parent c1f68254
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
......@@ -28,7 +28,7 @@ std::ofstream myfile;
myfile.open("data after cluster.txt");
myfile << A;
myfile.close();
std::ofstream myfile2;
myfile2.open("cluster centroids.txt");
myfile2 << clusters;
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
......@@ -4,7 +4,6 @@
#define M_PI 3.14159265358979323846
#endif
#include "armadillo.h"
#include <cmath>
using namespace arma;
class ba_system_collisionDetection_rectIntersection_1__lineIntersection_1_{
public:
......@@ -29,7 +28,7 @@ double Cy = lineA(2-1, 1-1)-lineB(2-1, 1-1);
double n1 = Ay*Bx-Ax*By;
double cutoff = 1.0E-8;
bool res = false;
if(((std::abs(n1) > cutoff))){
if((((abs(n1)) > cutoff))){
double alpha = (By*Cx-Bx*Cy)/n1;
if(((alpha >= cutoff))&&((alpha <= 1))){
double beta = (Ax*Cy-Ay*Cx)/n1;
......
......@@ -28,7 +28,7 @@ std::ofstream myfile;
myfile.open("data after cluster.txt");
myfile << A;
myfile.close();
std::ofstream myfile2;
myfile2.open("cluster centroids.txt");
myfile2 << clusters;
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
......@@ -85,8 +85,8 @@ timeCutoffFilter.init(2);
void execute()
{
timeCutoffFilter.collisionIn = firstLineIntersection.collisionOut;
timeCutoffFilter.indexInA = firstLineIntersection.linexA;
timeCutoffFilter.indexInB = firstLineIntersection.linexB;
timeCutoffFilter.indexInA = firstLineIntersection.lIndexA;
timeCutoffFilter.indexInB = firstLineIntersection.lIndexB;
timeCutoffFilter.colPosIn = firstLineIntersection.pos;
timeCutoffFilter.trajectoryInA = trajectoryA;
timeCutoffFilter.trajectoryInB = trajectoryB;
......
......@@ -12,8 +12,8 @@ public:
bool collisionIn[45];
mat pointsIn[45];
bool collisionOut;
int linexA;
int linexB;
int lIndexA;
int lIndexB;
mat pos;
void init()
{
......@@ -72,8 +72,8 @@ for( auto i=1;i<=m1;++i){
for( auto j=i;j<=m1;++j){
if((found == false)){
if(collisionIn[k-1]){
linexA = i;
linexB = j;
lIndexA = i;
lIndexB = j;
pos = pointsIn[k-1];
found = true;
}
......
......@@ -28,7 +28,7 @@ double Cy = lineA(2-1, 1-1)-lineB(2-1, 1-1);
double n1 = Ay*Bx-Ax*By;
double cutoff = 1.0E-8;
bool res = false;
if(((std::abs(n1) > cutoff))){
if((((abs(n1)) > cutoff))){
double alpha = (By*Cx-Bx*Cy)/n1;
if(((alpha >= cutoff))&&((alpha <= 1))){
double beta = (Ax*Cy-Ay*Cx)/n1;
......
......@@ -5,7 +5,6 @@
#endif
#include "armadillo.h"
#include "HelperA.h"
#include <cmath>
using namespace arma;
class ba_system_intersectionController_trajectoryCollision_1__timeCutoffFilter{
const int m = 10;
......@@ -49,7 +48,7 @@ aIsFasterOut = true;
else {
aIsFasterOut = false;
}
collisionOut = (std::abs(time1-time2) < timeCutoff);
collisionOut = ((abs(time1-time2)) < timeCutoff);
}
else {
collisionOut = false;
......
......@@ -27,7 +27,7 @@ lineOut[8]=mat(4,1);
void execute()
{
for( auto i=1;i<=m1;++i){
colvec tmpLine = colvec(4);
colvec tmpLine=colvec(4);
tmpLine(1-1, 1-1) = trajectoryIn(1-1, i-1);
tmpLine(2-1, 1-1) = trajectoryIn(2-1, i-1);
tmpLine(3-1, 1-1) = trajectoryIn(1-1, i+1-1);
......
......@@ -27,7 +27,7 @@ lineOut[8]=mat(4,1);
void execute()
{
for( auto i=1;i<=m1;++i){
colvec tmpLine = colvec(4);
colvec tmpLine=colvec(4);
tmpLine(1-1, 1-1) = trajectoryIn(1-1, i-1);
tmpLine(2-1, 1-1) = trajectoryIn(2-1, i-1);
tmpLine(3-1, 1-1) = trajectoryIn(1-1, i+1-1);
......
#ifndef BA_STRUCT_POINT
#define BA_STRUCT_POINT
struct ba_struct_Point {
double posX = 0.0;
double posY = 0.0;
};
#endif
#ifndef BA_STRUCT_RECTANGLE
#define BA_STRUCT_RECTANGLE
#include "ba_struct_Point.h"
struct ba_struct_Rectangle {
ba_struct_Point pointA;
ba_struct_Point pointB;
ba_struct_Point pointC;
ba_struct_Point pointD;
};
#endif
......@@ -28,7 +28,7 @@ std::ofstream myfile;
myfile.open("data after cluster.txt");
myfile << A;
myfile.close();
std::ofstream myfile2;
myfile2.open("cluster centroids.txt");
myfile2 << clusters;
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
#ifndef BA_STRUCT_POINT
#define BA_STRUCT_POINT
struct ba_struct_Point {
double posX = 0.0;
double posY = 0.0;
};
#endif
#ifndef BA_STRUCT_RECTANGLE
#define BA_STRUCT_RECTANGLE
#include "ba_struct_Point.h"
struct ba_struct_Rectangle {
ba_struct_Point pointA;
ba_struct_Point pointB;
ba_struct_Point pointC;
ba_struct_Point pointD;
};
#endif
......@@ -28,7 +28,7 @@ std::ofstream myfile;
myfile.open("data after cluster.txt");
myfile << A;
myfile.close();
std::ofstream myfile2;
myfile2.open("cluster centroids.txt");
myfile2 << clusters;
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
#ifndef BA_STRUCT_POINT
#define BA_STRUCT_POINT
struct ba_struct_Point {
double posX = 0.0;
double posY = 0.0;
};
#endif
#ifndef BA_STRUCT_RECTANGLE
#define BA_STRUCT_RECTANGLE
#include "ba_struct_Point.h"
struct ba_struct_Rectangle {
ba_struct_Point pointA;
ba_struct_Point pointB;
ba_struct_Point pointC;
ba_struct_Point pointD;
};
#endif
......@@ -28,7 +28,7 @@ std::ofstream myfile;
myfile.open("data after cluster.txt");
myfile << A;
myfile.close();
std::ofstream myfile2;
myfile2.open("cluster centroids.txt");
myfile2 << clusters;
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
#ifndef BA_STRUCT_POINT
#define BA_STRUCT_POINT
struct ba_struct_Point {
double posX = 0.0;
double posY = 0.0;
};
#endif
#ifndef BA_STRUCT_RECTANGLE
#define BA_STRUCT_RECTANGLE
#include "ba_struct_Point.h"
struct ba_struct_Rectangle {
ba_struct_Point pointA;
ba_struct_Point pointB;
ba_struct_Point pointC;
ba_struct_Point pointD;
};
#endif
......@@ -28,7 +28,7 @@ std::ofstream myfile;
myfile.open("data after cluster.txt");
myfile << A;
myfile.close();
std::ofstream myfile2;
myfile2.open("cluster centroids.txt");
myfile2 << clusters;
......@@ -76,12 +76,8 @@ static double getEuclideanDistance(mat A, int colIndexA, mat B, int colIndexB){
}
static mat getSqrtMat(mat A){
for(int i=0;i<A.n_rows;++i){
double curVal = A(i,i);
A(i,i) = sqrt(curVal);
}
return A;
cx_mat result=sqrtmat(A);
return real(result);
}
static mat getSqrtMatDiag(mat A){
......
#ifndef BA_STRUCT_POINT
#define BA_STRUCT_POINT
struct ba_struct_Point {
double posX = 0.0;
double posY = 0.0;
};
#endif
#ifndef BA_STRUCT_RECTANGLE
#define BA_STRUCT_RECTANGLE
#include "ba_struct_Point.h"
struct ba_struct_Rectangle {
ba_struct_Point pointA;
ba_struct_Point pointB;
ba_struct_Point pointC;
ba_struct_Point pointD;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment