


public int Find_UV_PointQuality(Vector3 vTestPoint)//thinking about generalizing
{
Vector2 vTestScaled;
float rHex = Mathf.Tan(Mathf.PI / 6);//units normalized to fCelHeight
Vector2 vCT_M;
Vector2 A, AB, BC, AM;
vTestScaled.x = vTestPoint.x; vTestScaled.y = vTestPoint.y;
vTestScaled /= m_fCelHt;
sWrite.WriteLine("vTestPoint = " + vTestPoint.ToString("F3") + " vTestScaled = " + vTestScaled.ToString("F3"));
for (int i = 0; i< 19; i++)
{
vCT_M = vTestScaled - vQualCenter[i];
sWrite.WriteLine("vCT_M = " + vCT_M.ToString("F3") + " vQualCenter[i] = " + vQualCenter[i].ToString("F3") + " i = " + i.ToString());
if (vCT_M.magnitude < rHex)
{
A.x = -rHex;
A.y = -1f / 2f;
AB.x = 0;
AB.y = 1;
BC.x = 2 * rHex;
BC.y = 0f;
AM = vCT_M - A;
int VerfiedCnt = 0;
float dotAB_AM;
float dotAB_AB;
float dotBC_AM;
float dotBC_BC;
sWrite.WriteLine("A = " + A.ToString("F3") + " AB = " + AB.ToString("F3") + " BC = " + BC.ToString("F3") + " AM = " + AM.ToString());
for (int j = 0; j < 3; j++)
{
dotAB_AM = Vector2.Dot(AB, AM);
dotAB_AB = Vector2.Dot(AB, AB);
dotBC_AM = Vector2.Dot(BC, AM);
dotBC_BC = Vector2.Dot(BC, BC);
sWrite.WriteLine("Rectangle test:");
sWrite.WriteLine("dotAB_AM = " + dotAB_AM.ToString("F3") + " dotAB_AB = " + dotAB_AB.ToString("F3") + " dotBC_AM = " + dotBC_AM.ToString() +
" dotBC_BC = " + dotBC_BC.ToString() + " J = " + j.ToString() + " i = " + i.ToString() + " VerfiedCnt = " + VerfiedCnt.ToString() );
sWrite.WriteLine("A = " + A.ToString("F3") + " AB = " + AB.ToString("F3") + " BC = " + BC.ToString() );
sWrite.WriteLine("------------------------------------");
if (dotAB_AM >= 0 && dotAB_AM <= dotAB_AB && dotBC_AM >= 0 && dotBC_AM <= dotBC_BC)
{
if(++VerfiedCnt == 3)
{
sWrite.WriteLine("Found = " + i.ToString());
sWrite.WriteLine("--- Next ---");
sWrite.WriteLine(" ");
return i;
}
Rota2D_CW(ref A, Mathf.PI / 3);
Rota2D_CW(ref AB, Mathf.PI / 3);
Rota2D_CW(ref BC, Mathf.PI / 3);
AM = vCT_M - A;
}
}
}
}
sWrite.WriteLine("RETURN - NOT FOUND");
sWrite.WriteLine("--- Next ---");
sWrite.WriteLine(" ");
return TriQual.UNDEFINED;
}
Call at ArgosSolidAnglePainter Start()
//unit test - Find_UV_PointQuality(Vector3 vTestPoint);
Update();
float x = -m_fRadius_UV*0.95f;
float y = m_fRadius_UV*0.95f;
float dx = (-2f) * x / 11f;
float dy = 2f * y / 11;
Vector3 vTest = Vector3.zero;
vTest.x = x;
vTest.y = y;
int TestResult;
for (int i = 0; i<12; i++)
{
for(int j = 0; j<12;j++)
{
sWrite.WriteLine("");
sWrite.WriteLine("/************ RUNNING TEST AT: i = " + i.ToString() + " j = " + j.ToString() + " x = " + vTest.x.ToString("F3") + " y = " + vTest.y.ToString("F3") + " **************/");
TestResult = Find_UV_PointQuality(vTest);
vTest.x += dx;
}
vTest.y -= dy;
vTest.x = x;
}
sWrite.Close();
}
void Update()
{
m_vnPointing = transform.forward;
m_vPointingLoc = m_vnPointing * cosaHedra.radius;
Angle_to_Rotate = 360 / (float)NUM_cells_Circ;
m_fCelHt = Mathf.Tan(2f * Mathf.PI * Angle_to_Rotate / 360f) * cosaHedra.radius; //TOA -> AO/A = O
m_rHex = Mathf.Tan(Mathf.PI / 6f) * m_fCelHt;
m_fRadius_UV = (256f / 121f) * m_fCelHt;//from texture
}
Results
kl;kl;
public int Find_UV_PointQuality(Vector3 vTestPoint)//thinking about generalizing
{
Vector2 vTestScaled;
float rHex = Mathf.Tan(Mathf.PI / 6);//units normalized to fCelHeight
Vector2 vCT_M;
Vector2 A, AB, BC, AM;
vTestScaled.x = vTestPoint.x; vTestScaled.y = vTestPoint.y;
vTestScaled /= m_fCelHt;
sWrite.WriteLine("vTestPoint = " + vTestPoint.ToString("F3") + " vTestScaled = " + vTestScaled.ToString("F3"));
for (int i = 0; i< 19; i++)
{
vCT_M = vTestScaled - vQualCenter[i];
sWrite.WriteLine("vCT_M = " + vCT_M.ToString("F3") + " vQualCenter[i] = " + vQualCenter[i].ToString("F3") + " i = " + i.ToString());
if (vCT_M.magnitude < rHex)
{
A.x = -rHex;
A.y = -1f / 2f;
AB.x = 0;
AB.y = 1;
BC.x = 2 * rHex;
BC.y = 0f;
AM = vCT_M - A;
int VerfiedCnt = 0;
float dotAB_AM;
float dotAB_AB;
float dotBC_AM;
float dotBC_BC;
sWrite.WriteLine("A = " + A.ToString("F3") + " AB = " + AB.ToString("F3") + " BC = " + BC.ToString("F3") + " AM = " + AM.ToString());
for (int j = 0; j < 3; j++)
{
dotAB_AM = Vector2.Dot(AB, AM);
dotAB_AB = Vector2.Dot(AB, AB);
dotBC_AM = Vector2.Dot(BC, AM);
dotBC_BC = Vector2.Dot(BC, BC);
sWrite.WriteLine("Rectangle test:");
sWrite.WriteLine("dotAB_AM = " + dotAB_AM.ToString("F3") + " dotAB_AB = " + dotAB_AB.ToString("F3") + " dotBC_AM = " + dotBC_AM.ToString() +
" dotBC_BC = " + dotBC_BC.ToString() + " J = " + j.ToString() + " i = " + i.ToString() + " VerfiedCnt = " + VerfiedCnt.ToString() );
sWrite.WriteLine("A = " + A.ToString("F3") + " AB = " + AB.ToString("F3") + " BC = " + BC.ToString() );
sWrite.WriteLine("------------------------------------");
if (dotAB_AM > 0 && dotAB_AM < dotAB_AB && dotBC_AM > 0 && dotBC_AM < dotBC_BC)
{
if(++VerfiedCnt == 3)
{
sWrite.WriteLine("Found = " + i.ToString());
return i;
}
Rota2D_CW(ref A, Mathf.PI / 3);
Rota2D_CW(ref AB, Mathf.PI / 3);
Rota2D_CW(ref BC, Mathf.PI / 3);
AM = vCT_M - A;
}
}
}
}
return TriQual.UNDEFINED;
}
kl

Test Code
public int Find_UV_PointQuality(Vector3 vTestPoint)//thinking about generalizing
{
Vector2 vTestScaled;
float rHex = Mathf.Tan(Mathf.PI / 6);//units normalized to fCelHeight
Vector2 vCT_M;
Vector2 A, AB, BC, AM;
vTestScaled.x = vTestPoint.x; vTestScaled.y = vTestPoint.y;
vTestScaled /= m_fCelHt;
for (int i = 0; i< 18; i++)
{
vCT_M = vTestScaled - vQualCenter[i];
if (vCT_M.magnitude < rHex)
{
A.x = -rHex;
A.y = -1 / 2;
AB.x = 0;
AB.y = 1;
BC.x = 2 * rHex;
BC.y = 0f;
AM = vCT_M - A;
int VerfiedCnt = 0;
float dotAB_AM;
float dotAB_AB;
float dotBC_AM;
float dotBC_BC;
A = Vector2.up;
AB = Vector2.right;
BC = new Vector2(1, 1);
for (int j = 0; j < 3; j++)
{
dotAB_AM = Vector2.Dot(AB, AM);
dotAB_AB = Vector2.Dot(AB, AB);
dotBC_AM = Vector2.Dot(BC, AM);
dotBC_BC = Vector2.Dot(BC, BC);
sWrite.WriteLine("J = " + j.ToString() + " i = " + i.ToString() + " VerfiedCnt = " + VerfiedCnt.ToString() + " A = " + A.ToString("F3") + " AB = " + AB.ToString("F3") + " BC = " + BC.ToString() + " Before");
Rota2D_CW(ref A, Mathf.PI / 6);
Rota2D_CW(ref AB, Mathf.PI / 6);
Rota2D_CW(ref BC, Mathf.PI / 6);
sWrite.WriteLine("A = " + A.ToString("F3") + " AB = " + AB.ToString("F3") + " BC = " + BC.ToString() + " After");
sWrite.WriteLine("------------------------------------");
if (dotAB_AM > 0 && dotAB_AM < dotAB_AB && dotBC_AM > 0 && dotBC_AM < dotBC_BC)
{
if(++VerfiedCnt == 3)
{
//In This Cell
return i;
}
AM = vCT_M - A;
}
}
}
}
return TriQual.UNDEFINED;
}
public void Rota2D_CW(ref Vector2 v, float thetaRadCW)
{
float cs = Mathf.Cos(-thetaRadCW);
float sn = Mathf.Sin(-thetaRadCW);
Vector2 vtmp = v;
v.x = vtmp.x * cs - vtmp.y * sn;
v.y = vtmp.x * sn + vtmp.y * cs;
}
Output
J = 0 i = 7 VerfiedCnt = 0 A = (0.000, 1.000) AB = (1.000, 0.000) BC = (1.0, 1.0) Before A = (0.500, 0.866) AB = (0.866, -0.500) BC = (1.4, 0.4) After ------------------------------------ J = 1 i = 7 VerfiedCnt = 1 A = (0.500, 0.866) AB = (0.866, -0.500) BC = (1.4, 0.4) Before A = (0.866, 0.500) AB = (0.500, -0.866) BC = (1.4, -0.4) After ------------------------------------ J = 2 i = 7 VerfiedCnt = 1 A = (0.866, 0.500) AB = (0.500, -0.866) BC = (1.4, -0.4) Before A = (1.000, 0.000) AB = (0.000, -1.000) BC = (1.0, -1.0) After ------------------------------------ J = 0 i = 7 VerfiedCnt = 0 A = (0.000, 1.000) AB = (1.000, 0.000) BC = (1.0, 1.0) Before A = (0.500, 0.866) AB = (0.866, -0.500) BC = (1.4, 0.4) After ------------------------------------ J = 1 i = 7 VerfiedCnt = 1 A = (0.500, 0.866) AB = (0.866, -0.500) BC = (1.4, 0.4) Before A = (0.866, 0.500) AB = (0.500, -0.866) BC = (1.4, -0.4) After ------------------------------------ J = 2 i = 7 VerfiedCnt = 1 A = (0.866, 0.500) AB = (0.500, -0.866) BC = (1.4, -0.4) Before A = (1.000, 0.000) AB = (0.000, -1.000) BC = (1.0, -1.0) After ------------------------------------ J = 0 i = 7 VerfiedCnt = 0 A = (0.000, 1.000) AB = (1.000, 0.000) BC = (1.0, 1.0) Before A = (0.500, 0.866) AB = (0.866, -0.500) BC = (1.4, 0.4) After ------------------------------------ J = 1 i = 7 VerfiedCnt = 1 A = (0.500, 0.866) AB = (0.866, -0.500) BC = (1.4, 0.4) Before A = (0.866, 0.500) AB = (0.500, -0.866) BC = (1.4, -0.4) After ------------------------------------ J = 2 i = 7 VerfiedCnt = 1 A = (0.866, 0.500) AB = (0.500, -0.866) BC = (1.4, -0.4) Before A = (1.000, 0.000) AB = (0.000, -1.000) BC = (1.0, -1.0) After
public int Find_UV_PointQuality(Vector3 vTestPoint)//thinking about generalizing
{
Vector2 vTestScaled;
float rHex = Mathf.Tan(Mathf.PI / 6);//units normalized to fCelHeight
Vector2 vCT_M;
Vector2 A, AB, BC, AM;
vTestScaled.x = vTestPoint.x; vTestScaled.y = vTestPoint.y;
vTestScaled /= m_fCelHt;
for (int i = 0; i< 18; i++)
{
vCT_M = vTestScaled - vQualCenter[i];
if (vCT_M.magnitude < rHex)
{
A.x = -rHex;
A.y = -1 / 2;
AB.x = 0;
AB.y = 1;
BC.x = 2 * rHex;
BC.y = 0f;
AM = vCT_M - A;
int VerfiedCnt = 0;
float dotAB_AM;
float dotAB_AB;
float dotBC_AM;
float dotBC_BC;
for (int j = 0; j < 3; j++)
{
dotAB_AM = Vector2.Dot(AB, AM);
dotAB_AB = Vector2.Dot(AB, AB);
dotBC_AM = Vector2.Dot(BC, AM);
dotBC_BC = Vector2.Dot(BC, BC);
if (dotAB_AM > 0 && dotAB_AM < dotAB_AB && dotBC_AM > 0 && dotBC_AM < dotBC_BC)
{
if(++VerfiedCnt == 3)
{
//In This Cell
return i;
}
Rota2D(ref A, Mathf.PI / 3);
Rota2D(ref AB, Mathf.PI / 3);
Rota2D(ref BC, Mathf.PI / 3);
AM = vCT_M - A;
}
}
}
}
return TriQual.UNDEFINED;
}
unit test
Update();
float x = -1.4f * m_fRadius_UV;
float y = 1.4f * m_fRadius_UV;
float dx = (-2) * x / 11;
float dy = 2 * y / 11;
Vector3 vTest = Vector3.zero;
vTest.x = x;
vTest.y = y;
int TestResult;
for (int i = 0; i<11; i++)
{
for(int j = 0; j<11;j++)
{
TestResult = Find_UV_PointQuality(vTest);
sWrite.WriteLine("Test result = " + TestResult.ToString() + " Vector Tested = " + vTest.ToString("F3"));
vTest.x += dx;
}
vTest.y -= dy;
vTest.x = x;
}
sWrite.Close();



