Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
change the atan2 function into a wrapped SDL::phi function
Browse files Browse the repository at this point in the history
  • Loading branch information
YonsiG committed Jul 7, 2023
1 parent 32c54ff commit 0acd6fc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions SDL/Quintuplet.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBBB(struct SDL::modules& modulesIn

float alpha_OutUp,alpha_OutUp_highEdge,alpha_OutUp_lowEdge;

alpha_OutUp = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);
alpha_OutUp = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);

alpha_OutUp_highEdge = alpha_OutUp;
alpha_OutUp_lowEdge = alpha_OutUp;
Expand All @@ -1799,27 +1799,27 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBBB(struct SDL::modules& modulesIn
float tl_axis_lowEdge_x = tl_axis_x;
float tl_axis_lowEdge_y = tl_axis_y;

betaIn = alpha_InLo - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]);
betaIn = alpha_InLo - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]);

float betaInRHmin = betaIn;
float betaInRHmax = betaIn;
betaOut = -alpha_OutUp + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]);
betaOut = -alpha_OutUp + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]);

float betaOutRHmin = betaOut;
float betaOutRHmax = betaOut;

if(isEC_lastLayer)
{
alpha_OutUp_highEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
alpha_OutUp_lowEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);
alpha_OutUp_highEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
alpha_OutUp_lowEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);

tl_axis_highEdge_x = mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex];
tl_axis_highEdge_y = mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];
tl_axis_lowEdge_x = mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex];
tl_axis_lowEdge_y = mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];

betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(atan2f(tl_axis_highEdge_y,tl_axis_highEdge_x)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(atan2f(tl_axis_lowEdge_y,tl_axis_lowEdge_x)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);
betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_highEdge_x, tl_axis_highEdge_y)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_lowEdge_x, tl_axis_lowEdge_y)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);
}

//beta computation
Expand Down Expand Up @@ -1997,7 +1997,7 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBEE(struct SDL::modules& modulesIn
float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]);
float sdOut_alpha = sdIn_alpha; //weird

float sdOut_alphaOut = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);
float sdOut_alphaOut = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);

float sdOut_alphaOut_min = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex]));
float sdOut_alphaOut_max = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex]));
Expand All @@ -2006,11 +2006,11 @@ __device__ bool SDL::runQuintupletDefaultAlgoBBEE(struct SDL::modules& modulesIn
float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];
float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex];

betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]);
betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]);

float betaInRHmin = betaIn;
float betaInRHmax = betaIn;
betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]);
betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]);

float betaOutRHmin = betaOut;
float betaOutRHmax = betaOut;
Expand Down Expand Up @@ -2226,13 +2226,13 @@ __device__ bool SDL::runQuintupletDefaultAlgoEEEE(struct SDL::modules& modulesIn
float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];
float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex];

betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]);
betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]);
float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]);
float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]);
float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha;
float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha;

betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]);
betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]);

float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut;
float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut;
Expand Down
2 changes: 1 addition & 1 deletion SDL/Segment.cu
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ __device__ bool SDL::runSegmentDefaultAlgoBarrel(struct modules& modulesInGPU, s
pass = pass and (fabsf(dPhi) <= sdCut);
if(not pass) return pass;

dPhiChange = SDL::phi_mpi_pi(atan2f(yOut-yIn, xOut-xIn)-mdsInGPU.anchorPhi[innerMDIndex]);
dPhiChange = SDL::phi_mpi_pi(SDL::phi(xOut-xIn, yOut-yIn)-mdsInGPU.anchorPhi[innerMDIndex]);

pass = pass and (fabsf(dPhiChange) <= sdCut);
if(not pass) return pass;
Expand Down
24 changes: 12 additions & 12 deletions SDL/Triplet.cu
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ __device__ bool SDL::runTripletDefaultAlgoBBBB(struct SDL::modules& modulesInGPU

float alpha_OutUp,alpha_OutUp_highEdge,alpha_OutUp_lowEdge;

alpha_OutUp = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);
alpha_OutUp = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);

alpha_OutUp_highEdge = alpha_OutUp;
alpha_OutUp_lowEdge = alpha_OutUp;
Expand All @@ -810,28 +810,28 @@ __device__ bool SDL::runTripletDefaultAlgoBBBB(struct SDL::modules& modulesInGPU
float tl_axis_lowEdge_x = tl_axis_x;
float tl_axis_lowEdge_y = tl_axis_y;

betaIn = alpha_InLo - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]);
betaIn = alpha_InLo - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]);

float betaInRHmin = betaIn;
float betaInRHmax = betaIn;
betaOut = -alpha_OutUp + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]);
betaOut = -alpha_OutUp + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]);

float betaOutRHmin = betaOut;
float betaOutRHmax = betaOut;

if(isEC_lastLayer)
{
alpha_OutUp_highEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
alpha_OutUp_lowEdge = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);
alpha_OutUp_highEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
alpha_OutUp_lowEdge = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);

tl_axis_highEdge_x = mdsInGPU.anchorHighEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex];
tl_axis_highEdge_y = mdsInGPU.anchorHighEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];
tl_axis_lowEdge_x = mdsInGPU.anchorLowEdgeX[fourthMDIndex] - mdsInGPU.anchorX[firstMDIndex];
tl_axis_lowEdge_y = mdsInGPU.anchorLowEdgeY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];


betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(atan2f(tl_axis_highEdge_y,tl_axis_highEdge_x)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(atan2f(tl_axis_lowEdge_y,tl_axis_lowEdge_x)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);
betaOutRHmin = -alpha_OutUp_highEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_highEdge_x, tl_axis_highEdge_y)-mdsInGPU.anchorHighEdgePhi[fourthMDIndex]);
betaOutRHmax = -alpha_OutUp_lowEdge + SDL::phi_mpi_pi(SDL::phi(tl_axis_lowEdge_x, tl_axis_lowEdge_y)-mdsInGPU.anchorLowEdgePhi[fourthMDIndex]);
}

//beta computation
Expand Down Expand Up @@ -1010,7 +1010,7 @@ __device__ bool SDL::runTripletDefaultAlgoBBEE(struct SDL::modules& modulesInGPU
float sdIn_alpha_max = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]);
float sdOut_alpha = sdIn_alpha; //weird

float sdOut_alphaOut = SDL::phi_mpi_pi(atan2f(mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex],mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);
float sdOut_alphaOut = SDL::phi_mpi_pi(SDL::phi(mdsInGPU.anchorX[fourthMDIndex] - mdsInGPU.anchorX[thirdMDIndex], mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[thirdMDIndex])-mdsInGPU.anchorPhi[fourthMDIndex]);

float sdOut_alphaOut_min = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMins[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMins[outerSegmentIndex]));
float sdOut_alphaOut_max = SDL::phi_mpi_pi(__H2F(segmentsInGPU.dPhiChangeMaxs[outerSegmentIndex]) - __H2F(segmentsInGPU.dPhiMaxs[outerSegmentIndex]));
Expand All @@ -1019,11 +1019,11 @@ __device__ bool SDL::runTripletDefaultAlgoBBEE(struct SDL::modules& modulesInGPU
float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];
float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex];

betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]);
betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]);

float betaInRHmin = betaIn;
float betaInRHmax = betaIn;
betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]);
betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]);

float betaOutRHmin = betaOut;
float betaOutRHmax = betaOut;
Expand Down Expand Up @@ -1240,14 +1240,14 @@ __device__ bool SDL::runTripletDefaultAlgoEEEE(struct SDL::modules& modulesInGPU
float tl_axis_y = mdsInGPU.anchorY[fourthMDIndex] - mdsInGPU.anchorY[firstMDIndex];
float tl_axis_z = mdsInGPU.anchorZ[fourthMDIndex] - mdsInGPU.anchorZ[firstMDIndex];

betaIn = sdIn_alpha - SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[firstMDIndex]);
betaIn = sdIn_alpha - SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[firstMDIndex]);

float sdIn_alphaRHmin = __H2F(segmentsInGPU.dPhiChangeMins[innerSegmentIndex]);
float sdIn_alphaRHmax = __H2F(segmentsInGPU.dPhiChangeMaxs[innerSegmentIndex]);
float betaInRHmin = betaIn + sdIn_alphaRHmin - sdIn_alpha;
float betaInRHmax = betaIn + sdIn_alphaRHmax - sdIn_alpha;

betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(atan2f(tl_axis_y,tl_axis_x)-mdsInGPU.anchorPhi[fourthMDIndex]);
betaOut = -sdOut_alphaOut + SDL::phi_mpi_pi(SDL::phi(tl_axis_x, tl_axis_y)-mdsInGPU.anchorPhi[fourthMDIndex]);

float betaOutRHmin = betaOut - sdOut_alphaOutRHmin + sdOut_alphaOut;
float betaOutRHmax = betaOut - sdOut_alphaOutRHmax + sdOut_alphaOut;
Expand Down

0 comments on commit 0acd6fc

Please sign in to comment.