void IMGDock::rotateLigandFragment(Size fragment, Size bond, int degree) { const vector<StaticLigandFragment*>* ligand_fragments = scoring_function_->getStaticLigandFragments(); if (ligand_fragments->size() < fragment) { String s="There are less than "; s = s+String(fragment+1)+" fragments!"; throw Exception::GeneralException(__FILE__, __LINE__, "Rotation error", s); return; } StaticLigandFragment* lf = (*ligand_fragments)[fragment]; if (lf->connections.size() < bond) { String s="Fragment has less than "; s = s+String(bond+1)+" bonds!"; throw Exception::GeneralException(__FILE__, __LINE__, "Rotation error", s); return; } StaticLigandFragment::Connection* nc = &lf->connections[bond]; TMatrix4x4<float> M; TAngle<float> angle(degree, false); Vector3 axis = nc->neighbor_atom->getPosition() - nc->atom->getPosition(); M.setRotation(angle, axis); Vector3 origin = nc->atom->getPosition(); rotateLigandFragment(lf, M, origin, nc->fragment->ID); }
DGLE_RESULT DGLE_API CFixedFunctionPipeline::GetSpotLightConfiguration(uint uiIdx, TPoint3 &stPosition, TVector3 &stDirection, float &fRange, float &fSpotAngle) { E_LIGHT_TYPE type; GetLightType(uiIdx, type); if (uiIdx >= (uint)_iMaxLights || type != LT_SPOT) return E_INVALIDARG; GLfloat pos[4]; glGetLightfv(GL_LIGHT0 + uiIdx, GL_POSITION, pos); glGetLightfv(GL_LIGHT0 + uiIdx, GL_SPOT_DIRECTION, stDirection); // May work wrong when light position was set or changed directly via OpenGL outside this class. const TMatrix4x4 inv_mview = MatrixInverse(_pLights[uiIdx].mview); stPosition = inv_mview.ApplyToPoint(TPoint3(pos[0], pos[1], pos[2])); stDirection = inv_mview.ApplyToVector(stDirection); glGetLightfv(GL_LIGHT0 + uiIdx, GL_SPOT_CUTOFF, &fSpotAngle); fSpotAngle *= 2.f; glGetLightfv(GL_LIGHT0 + uiIdx, GL_LINEAR_ATTENUATION, &fRange); fRange = _c_fAttenuationFactor / fRange; return S_OK; }
void GridAnalysis::moveProbeGroup_(const Vector3& destination) { TMatrix4x4<float> M; Vector3 translation_vector = destination-center_; M.setTranslation(translation_vector); for (AtomIterator it = probe_group_.beginAtom(); +it; it++) { it->setPosition(M*it->getPosition()); } center_ = destination; }
void IMGDock::translateLigand(Vector3& v) { TMatrix4x4<float> M; M.setTranslation(v); // transform all atoms of the ligand for (AtomIterator it = ligand_->beginAtom(); it != ligand_->endAtom(); it++) { it->setPosition(M*it->getPosition()); } }
void GridAnalysis::rotateProbeGroup_(int axis, int degree) { TMatrix4x4<float> M; TAngle<float> angle(degree, false); Vector3 axis_vector(axis == 0, axis == 1, axis == 2); M.setRotation(angle, axis_vector); for (AtomIterator it = probe_group_.beginAtom(); it != probe_group_.endAtom(); it++) { it->setPosition(M*(it->getPosition()-center_)+center_); } }
void IMGDock::rotateLigand(int a, int degree) { TMatrix4x4<float> M; TAngle<float> angle(degree, false); Vector3 axis(a == 0, a == 1, a == 2); M.setRotation(angle, axis); const Vector3& origin = scoring_function_->getLigandCenter(); for (AtomIterator it = ligand_->beginAtom(); it != ligand_->endAtom(); it++) { it->setPosition(M*(it->getPosition()-origin)+origin); } }
void ScoreGridSet::transform(TMatrix4x4 < float > & T) { TMatrix4x4<float> T_i; T.invert(T_i); // store inverse of T in T_i T_ *= T; T_i_ *= T_i ; // store the inverse of all transformations in T_i_ transformed_ = 1; origin_ = T*origin_; }
DGLE_RESULT DGLE_API CMesh::TransformVertices(const TMatrix4x4 &stTransMatrix) { if (!_pBuffer) return S_FALSE; TDrawDataDesc desc; uint stride, verts_data_size, verts_count, idxs_data_size, idxs_count; _CopyMeshData(desc, stride, verts_data_size, verts_count, idxs_data_size, idxs_count); for (uint i = 0; i < verts_count; ++i) { TPoint3 *p = reinterpret_cast<TPoint3 *>(&desc.pData[stride * i]); *p = stTransMatrix.ApplyToPoint(*p); } PARANOIC_CHECK_RES(_pBuffer->Reallocate(desc, verts_count, idxs_count, CRDM_TRIANGLES)); delete[] desc.pData; return S_OK; }