|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: |
float t_Min = 0.0f;
// Maximum distance ray can travel (makes it a segment, otherwise it would be infinite)
float t_Max = float.MaxValue;
float ood = 0.0f;
float t1 = 0.0f;
float t2 = 0.0f;
// Translate ray to OBB space
Vector3 min_Local = Origin - oBB.Position; // (P - C)
Vector3 max_Local = Origin - oBB.Position; // (P - C)
float min_X = Vector3.Dot(min_Local, oBB.Axis_X);
float max_X = Vector3.Dot(max_Local, oBB.Axis_X);
float min_Y = Vector3.Dot(min_Local, oBB.Axis_Y);
float max_Y = Vector3.Dot(max_Local, oBB.Axis_Y);
float min_Z = Vector3.Dot(min_Local, oBB.Axis_Z);
float max_Z = Vector3.Dot(max_Local, oBB.Axis_Z);
// For all 3 slabs
if (Math.Abs(Direction.X) < float.Epsilon)
{
// Ray is parallel to slab. No hit if origin (p in book) not within slab
if (Origin.X < min_X || Origin.X > max_X)
{
return false;
}
}
else
{
// Compute intersection t value of ray with near and far plane of slab
ood = 1.0f / Direction.X;
t1 = (min_X - Origin.X) * ood;
t2 = (max_X - Origin.X) * ood;
// Make (t1) be intersection with near plane, (t2) with far plane
if (t1 > t2)
{
Swap(ref t1, ref t2);
}
// Compute the intersection of slab intersection intervals
t_Min = Math.Max(t_Min, t1);
t_Max = Math.Min(t_Max, t2);
// Exit with no collision as soon as slab intersection becomes empty
if (t_Min > t_Max)
{
return false;
}
}
if (Math.Abs(Direction.Y) < float.Epsilon)
{
// Ray is parallel to slab. No hit if origin (p in book) not within slab
if (Origin.Y < min_Y || Origin.Y > max_Y)
{
return false;
}
}
else
{
// Compute intersection t value of ray with near and far plane of slab
ood = 1.0f / Direction.Y;
t1 = (min_Y - Origin.Y) * ood;
t2 = (max_Y - Origin.Y) * ood;
// Make (t1) be intersection with near plane, (t2) with far plane
if (t1 > t2)
{
Swap(ref t1, ref t2);
}
// Compute the intersection of slab intersection intervals
t_Min = Math.Max(t_Min, t1);
t_Max = Math.Min(t_Max, t2);
// Exit with no collision as soon as slab intersection becomes empty
if (t_Min > t_Max)
{
return false;
}
}
if (Math.Abs(Direction.Z) < float.Epsilon)
{
// Ray is parallel to slab. No hit if origin (p in book) not within slab
if (Origin.Z < min_Z || Origin.Z > max_Z)
{
return false;
}
}
else
{
// Compute intersection t value of ray with near and far plane of slab
ood = 1.0f / Direction.Z;
t1 = (min_Z - Origin.Z) * ood;
t2 = (max_Z - Origin.Z) * ood;
// Make (t1) be intersection with near plane, (t2) with far plane
if (t1 > t2)
{
Swap(ref t1, ref t2);
}
// Compute the intersection of slab intersection intervals
t_Min = Math.Max(t_Min, t1);
t_Max = Math.Min(t_Max, t2);
// Exit with no collision as soon as slab intersection becomes empty
if (t_Min > t_Max)
{
return false;
}
}
return true;
|
Advertisement
| Hall of Fame |