float LSeg3f::distToPoint(const Vec3f &point, Vec3f *closest) const { if (_is_degenerate) { if (closest != 0) closest->copy(_beg); return Vec3f::dist(point, _beg); } Vec3f p; float t; p.diff(point, _beg); t = Vec3f::dot(p, _diff) / _length_sqr; if (t < 0.f) p.copy(_beg); else if (t > 1.f) p.copy(_end); else p.lineCombin(_beg, _diff, t); if (closest != 0) closest->copy(p); return Vec3f::dist(point, p); }
void RenderContext::drawTextItemText (const TextItem& ti) { bool bold = ti.highlighted && opt.highlightThicknessEnable; Vec3f color; if (ti.ritype == RenderItem::RIT_AAM) color.copy(opt.aamColor); else if (ti.ritype == RenderItem::RIT_DATASGROUP) color.copy(opt.dataGroupColor); else if (ti.ritype == RenderItem::RIT_COMMENT) color.copy(opt.commentColor); else if (ti.ritype == RenderItem::RIT_TITLE) color.copy(opt.titleColor); else { getColorVec(color, ti.color); if (ti.highlighted && opt.highlightColorEnable) color.copy(opt.highlightColor); } drawTextItemText (ti, color, bold); }
void MoleculeSubstructureMatcher::getAtomPos (Graph &graph, int vertex_idx, Vec3f &pos) { pos.copy(((BaseMolecule &)graph).getAtomXyz(vertex_idx)); }