void inter_plan(t_all *all, t_object *plan) { double k; translate1(plan, &all->eye); rotate(all, plan); if (all->eye.vz != 0) k = -all->eye.z / all->eye.vz; else k = -1; if (k > 0.00001) { plan->k = k; my_cos(all, k, 2, plan); translate2(plan, &all->eye); unrotate(all); calc_lum_vector(all, plan); } else { printf("inside plan\n"); plan->k = -1; unrotate(all); translate2(plan, &all->eye); } }
void inter_cone2(t_all *all, t_object *cone, t_inter *i) { if (i->k < i->k2 && i->k > 0.00001) { cone->k = i->k; my_cos(all, i->k, 4, cone); translate2(cone, &all->eye); unrotate(all); calc_lum_vector(all, cone); } else if (i->k2 < i->k && i->k2 > 0.00001) { cone->k = i->k2; my_cos(all, i->k2, 4, cone); translate2(cone, &all->eye); unrotate(all); calc_lum_vector(all, cone); } else { unrotate(all); translate2(cone, &all->eye); } if (i->delta <= 0) cone->k = -1; }
int inter_cone_shadow(t_object *obj, t_spobject *lum) { t_inter i; protate(lum, obj); translate1(obj, lum); obj->xrot *= -1; obj->yrot *= -1; obj->zrot *= -1; rotate(lum, obj); i.d = 0; if (cos(obj->angle) != 0) i.d = sin(obj->angle) / cos(obj->angle); i.a = pow(lum->vx, 2) + pow(lum->vy, 2) - pow(lum->vz, 2) * pow(i.d, 2); i.b = 2 * (lum->x * lum->vx + lum->y * lum->vy - (lum->z * (lum->vz) * pow(i.d, 2))); i.c = pow(lum->x, 2) + pow(lum->y, 2) - pow(lum->z, 2) * pow(i.d, 2); i.delta = i.b * i.b - 4 * i.a * i.c; i.k = (i.b - sqrt(i.delta)) / (2 * i.a); i.k2 = (i.b + sqrt(i.delta)) / (2 * i.a); translate2(obj, lum); punrotate(lum); unrotate(lum); obj->xrot *= -1; obj->yrot *= -1; obj->zrot *= -1; return (inter_cone_shadow_delta(&i)); }
int inter_cyl_shadow(t_object *obj, t_spobject *lum) { t_inter i; protate(lum, obj); obj->xrot *= -1; obj->yrot *= -1; obj->zrot *= -1; translate1(obj, lum); rotate(lum, obj); i.a = pow(lum->vx, 2) + pow(lum->vy, 2); i.b = 2 * (lum->x * lum->vx + lum->y * lum->vy); i.c = pow(lum->x, 2) + pow(lum->y, 2) - pow(obj->ray, 2); i.delta = i.b * i.b - 4 * i.a * i.c; i.k = (i.b - sqrt(i.delta)) / (2 * i.a); i.k2 = (i.b + sqrt(i.delta)) / (2 * i.a); translate2(obj, lum); punrotate(lum); unrotate(lum); obj->xrot *= -1; obj->yrot *= -1; obj->zrot *= -1; if (i.delta >= 0) if ((i.k2 < 0.9999 && i.k2 > 0.00001) || (i.k < 0.9999 && i.k > 0.00001)) return (-1); return (0); }
/* ************************************************************************* */ Unit3 Rot3::unrotate(const Unit3& p, OptionalJacobian<2,3> HR, OptionalJacobian<2,2> Hp) const { Matrix32 Dp; Unit3 q = Unit3(unrotate(p.point3(Dp))); if (Hp) *Hp = q.basis().transpose() * matrix().transpose () * Dp; if (HR) *HR = q.basis().transpose() * q.skew(); return q; }
IDE_RC ideMsgLog::logBody(const SChar* aMsg, const size_t sLen) { if(mEnabled == ID_TRUE) { IDE_TEST(rotate() != IDE_SUCCESS); IDE_TEST(idlOS::write(mFD, aMsg, sLen) != (ssize_t)sLen); unrotate(); } else { /* pass */ } return IDE_SUCCESS; IDE_EXCEPTION_END; unrotate(); return IDE_FAILURE; }
void inter_cyl(t_all *all, t_object *cyl) { t_inter i; translate1(cyl, &all->eye); rotate(all, cyl); i.a = pow(all->eye.vx, 2) + pow(all->eye.vy, 2); i.b = 2 * (all->eye.x * all->eye.vx + all->eye.y * all->eye.vy); i.c = pow(all->eye.x, 2) + pow(all->eye.y, 2) - pow(cyl->ray, 2); i.delta = i.b * i.b - 4 * i.a * i.c; i.k = (-i.b - sqrt(i.delta)) / (2 * i.a); i.k2 = (-i.b + sqrt(i.delta)) / (2 * i.a); if (i.k < i.k2 && i.k > 0.00001) { cyl->k = i.k; my_cos(all, i.k, 3, cyl); unrotate(all); translate2(cyl, &all->eye); calc_lum_vector(all, cyl); } else if (i.k2 < i.k && i.k2 > 0.00001) { cyl->k = i.k2; my_cos(all, i.k2, 3, cyl); unrotate(all); translate2(cyl, &all->eye); calc_lum_vector(all, cyl); } else { unrotate(all); translate2(cyl, &all->eye); } if (i.delta <= 0) cyl->k = -1; }
int inter_plan_shadow(t_object *obj, t_spobject *lum) { double k; protate(lum, obj); translate1(obj, lum); obj->xrot *= -1; obj->yrot *= -1; obj->zrot *= -1; rotate(lum, obj); obj->xrot *= -1; obj->yrot *= -1; obj->zrot *= -1; k = lum->z / lum->vz; translate2(obj, lum); punrotate(lum); unrotate(lum); if (k < 0.9999 && k > 0.00001) return (-1); return (0); }
IDE_RC ideMsgLog::rotate(void) { idBool sNeedWriteMessage = ID_FALSE; if(mEnabled == ID_TRUE) { size_t sOffset; SInt sRotating; /* For IDE_ERR, do not perform rotation */ IDE_TEST_RAISE(mSelf == IDE_ERR, IAMERR); sRotating = acpAtomicCas32(&mRotating, 1, 0); if(sRotating == 1) { /* spin */ do { idlOS::thr_yield(); sRotating = acpAtomicCas32(&mRotating, 1, 0); } while(sRotating == 1); } else { /* fall through */ } if(checkExist() == ID_FALSE) { IDE_TEST(createFileAndHeader() != IDE_SUCCESS); } else { if ( isSameFile( mFD, mPath ) == ID_TRUE ) { /* do nothing */ } else { /* file is modified so close and open */ (void)close(); IDE_TEST( open( mDebug ) != IDE_SUCCESS ); sNeedWriteMessage = ID_TRUE; } if(mMaxNumber > 0) { sOffset = (size_t)idlOS::lseek(mFD, 0, SEEK_END); if(sOffset >= mSize) { IDE_TEST(closeAndRename() != IDE_SUCCESS); mCurNumber = (mCurNumber + 1) % mMaxNumber; IDE_TEST(createFileAndHeader() != IDE_SUCCESS); } else { /* do not create file */ } } else { /* fall through */ } if ( sNeedWriteMessage == ID_TRUE ) { IDE_TEST( writeWarningMessage() != IDE_SUCCESS ); } else { /* do nothing */ } } } else { /* pass */ } /* For IDE_ERR, do not perform rotation */ IDE_EXCEPTION_CONT(IAMERR); return IDE_SUCCESS; IDE_EXCEPTION_END; unrotate(); return IDE_FAILURE; }