![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| struct | quadmatrix |
| struct | quadric |
Functions | |
| quadric * | newquadric (void) |
| void | quadric_intersect (quadric *, ray *) |
| void | quadric_normal (quadric *, vector *, ray *, vector *) |
| quadric* newquadric | ( | void | ) |
Definition at line 83 of file quadric.cpp.
References quadric::ctr, quadric::methods, quadric_methods, rt_getmem(), vector::x, vector::y, and vector::z.
Referenced by rt_quadsphere().
Definition at line 96 of file quadric.cpp.
References quadmatrix::a, add_intersection(), quadmatrix::b, quadmatrix::c, quadric::ctr, quadmatrix::d, ray::d, quadmatrix::e, quadmatrix::f, quadmatrix::g, quadmatrix::h, quadmatrix::i, quadmatrix::j, quadric::mat, ray::o, VNorm(), vector::x, vector::y, and vector::z.
{
flt Aq, Bq, Cq;
flt t1, t2;
flt disc;
vector rd;
vector ro;
rd=ry->d;
VNorm(&rd);
ro.x = ry->o.x - q->ctr.x;
ro.y = ry->o.y - q->ctr.y;
ro.z = ry->o.z - q->ctr.z;
Aq = (q->mat.a*(rd.x * rd.x)) +
(2.0 * q->mat.b * rd.x * rd.y) +
(2.0 * q->mat.c * rd.x * rd.z) +
(q->mat.e * (rd.y * rd.y)) +
(2.0 * q->mat.f * rd.y * rd.z) +
(q->mat.h * (rd.z * rd.z));
Bq = 2.0 * (
(q->mat.a * ro.x * rd.x) +
(q->mat.b * ((ro.x * rd.y) + (rd.x * ro.y))) +
(q->mat.c * ((ro.x * rd.z) + (rd.x * ro.z))) +
(q->mat.d * rd.x) +
(q->mat.e * ro.y * rd.y) +
(q->mat.f * ((ro.y * rd.z) + (rd.y * ro.z))) +
(q->mat.g * rd.y) +
(q->mat.h * ro.z * rd.z) +
(q->mat.i * rd.z)
);
Cq = (q->mat.a * (ro.x * ro.x)) +
(2.0 * q->mat.b * ro.x * ro.y) +
(2.0 * q->mat.c * ro.x * ro.z) +
(2.0 * q->mat.d * ro.x) +
(q->mat.e * (ro.y * ro.y)) +
(2.0 * q->mat.f * ro.y * ro.z) +
(2.0 * q->mat.g * ro.y) +
(q->mat.h * (ro.z * ro.z)) +
(2.0 * q->mat.i * ro.z) +
q->mat.j;
if (Aq == 0.0) {
t1 = - Cq / Bq;
add_intersection(t1, (object *) q, ry);
}
else {
disc=(Bq*Bq - 4.0 * Aq * Cq);
if (disc > 0.0) {
disc=sqrt(disc);
t1 = (-Bq + disc) / (2.0 * Aq);
t2 = (-Bq - disc) / (2.0 * Aq);
add_intersection(t1, (object *) q, ry);
add_intersection(t2, (object *) q, ry);
}
}
}
Definition at line 157 of file quadric.cpp.
References quadmatrix::a, quadmatrix::b, quadmatrix::c, quadric::ctr, ray::d, quadmatrix::d, quadmatrix::e, quadmatrix::f, quadmatrix::g, quadmatrix::h, quadmatrix::i, quadric::mat, VDot(), VNorm(), vector::x, vector::y, and vector::z.
{
N->x = (q->mat.a*(pnt->x - q->ctr.x) +
q->mat.b*(pnt->y - q->ctr.y) +
q->mat.c*(pnt->z - q->ctr.z) + q->mat.d);
N->y = (q->mat.b*(pnt->x - q->ctr.x) +
q->mat.e*(pnt->y - q->ctr.y) +
q->mat.f*(pnt->z - q->ctr.z) + q->mat.g);
N->z = (q->mat.c*(pnt->x - q->ctr.x) +
q->mat.f*(pnt->y - q->ctr.y) +
q->mat.h*(pnt->z - q->ctr.z) + q->mat.i);
VNorm(N);
if (VDot(N, &(incident->d)) > 0.0) {
N->x=-N->x;
N->y=-N->y;
N->z=-N->z;
}
}
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.