bool Button::HandleEvents(const SDL_Event &Event) { if(Event.type==SDL_EventType::SDL_MOUSEMOTION) { if(PointInside(Event.motion.x, Event.motion.y)) { Selected=true; } else { Selected=false; } } else if(Event.type==SDL_EventType::SDL_MOUSEBUTTONDOWN) { if(Event.button.button==SDL_BUTTON_LEFT) { if(PointInside(Event.button.x, Event.button.y)) { OnClick(); } } } return true; }
float3 Frustum::FastRandomPointInside(LCG &rng) const { float f1 = rng.Float(-1.f, 1.f); float f2 = rng.Float(-1.f, 1.f); float f3 = rng.Float(0.f, 1.f); return PointInside(f1, f2, f3); }
vec AABB::RandomPointInside(LCG &rng) const { float f1 = rng.Float(); float f2 = rng.Float(); float f3 = rng.Float(); return PointInside(f1, f2, f3); }
void HistogramImg::OnLButtonDown(UINT flags, CPoint pos) { drawing_ = true; SetCapture(); PointInside(pos); selection_rect_.left = selection_rect_.right = pos.x; selection_rect_.top = selection_rect_.bottom = pos.y; CClientDC dc(this); dc.DrawFocusRect(selection_rect_); // SetCursor(); }
int SHAPE_LINE_CHAIN::Distance( const VECTOR2I& aP, bool aOutlineOnly ) const { int d = INT_MAX; if( IsClosed() && PointInside( aP ) && !aOutlineOnly ) return 0; for( int s = 0; s < SegmentCount(); s++ ) d = std::min( d, CSegment( s ).Distance( aP ) ); return d; }
// ************************************************************ // get hit result with a ray. RTHitResult RTPolygon::GetHitResult(RTRay *r) { // hit result means find out the intersection in the plane. // then, find out if the intersection point is within // the Vec3 vDirToOrigin = verts[0].Sub(r->vStart); vDirToOrigin.Normalize(); Vec3 vDirNormalized = r->vDir.GetNormalized(); GLfloat numerator = vec3_dot(&vNormal, &vDirToOrigin); GLfloat denominator = vec3_dot(&vNormal, &vDirNormalized); GLfloat t = (GLfloat) (numerator / denominator); RTHitResult hr; hr.Clear(); // if line wasn't parallel or directly on the plane, if(t >= 0) { // find point hit hr.vPointHit = r->PointAtTValue(t); // if point hit was not inside the polygon, if(!PointInside(&hr.vPointHit)) { // return a failed hit test. hr.bHit = false; return hr; } else { // return a hit result containing the point, normal, etc. hr.bHit = true; hr.t = t; hr.vNormalHit = vNormal; hr.matHit = mat; } } return hr; }
void HistogramImg::OnMouseMove(UINT flags, CPoint pos) { if (drawing_) { CClientDC dc(this); CRect rect= selection_rect_; rect.NormalizeRect(); dc.DrawFocusRect(rect); PointInside(pos); selection_rect_.right = pos.x; selection_rect_.bottom = pos.y; rect = selection_rect_; rect.NormalizeRect(); dc.DrawFocusRect(rect); SetCursor(); return; } CButton::OnMouseMove(flags, pos); }
/*---------------------------------------------------------------------------*/ BOOL8 DummyFastMatch ( FEATURE Feature, PROTO Proto) /* ** Parameters: ** Feature feature to be "fast matched" to proto ** Proto proto being "fast matched" against ** Globals: ** training_tangent_bbox_pad bounding box pad tangent to proto ** training_orthogonal_bbox_pad bounding box pad orthogonal to proto ** Operation: This routine returns TRUE if Feature would be matched ** by a fast match table built from Proto. ** Return: TRUE if feature could match Proto. ** Exceptions: none ** History: Wed Nov 14 17:19:58 1990, DSJ, Created. */ { FRECT BoundingBox; FLOAT32 MaxAngleError; FLOAT32 AngleError; MaxAngleError = training_angle_pad / 360.0; AngleError = fabs (Proto->Angle - Feature->Params[PicoFeatDir]); if (AngleError > 0.5) AngleError = 1.0 - AngleError; if (AngleError > MaxAngleError) return (FALSE); ComputePaddedBoundingBox (Proto, training_tangent_bbox_pad * GetPicoFeatureLength (), training_orthogonal_bbox_pad * GetPicoFeatureLength (), &BoundingBox); return PointInside(&BoundingBox, Feature->Params[PicoFeatX], Feature->Params[PicoFeatY]); } /* DummyFastMatch */
void CRimshotView::OnLButtonDown(UINT nFlags, CPoint point) { bool bHit = false; CRimshotDoc* pDoc = GetDocument(); if (pDoc->m_pInput) { for (int i=0; i<pDoc->m_pInput->nNumRanks; i++) { if (PointInside(point, m_Draw.pCursorRanks[i].rect)) { m_Draw.pCursorRanks[i].active = !m_Draw.pCursorRanks[i].active; //InvalidateRect(&m_Draw.pCursorRanks[i].rect); bHit = true; } } } if (bHit) { StopDrawing(); StartDrawing(); } CView::OnLButtonDown(nFlags, point); }
/** * This routine returns TRUE if Feature would be matched * by a fast match table built from Proto. * * @param Feature feature to be "fast matched" to proto * @param Proto proto being "fast matched" against * * Globals: * - training_tangent_bbox_pad bounding box pad tangent to proto * - training_orthogonal_bbox_pad bounding box pad orthogonal to proto * * @return TRUE if feature could match Proto. * @note Exceptions: none * @note History: Wed Nov 14 17:19:58 1990, DSJ, Created. */ BOOL8 DummyFastMatch ( FEATURE Feature, PROTO Proto) { FRECT BoundingBox; FLOAT32 MaxAngleError; FLOAT32 AngleError; MaxAngleError = training_angle_pad / 360.0; AngleError = fabs (Proto->Angle - Feature->Params[PicoFeatDir]); if (AngleError > 0.5) AngleError = 1.0 - AngleError; if (AngleError > MaxAngleError) return (FALSE); ComputePaddedBoundingBox (Proto, training_tangent_bbox_pad * GetPicoFeatureLength (), training_orthogonal_bbox_pad * GetPicoFeatureLength (), &BoundingBox); return PointInside(&BoundingBox, Feature->Params[PicoFeatX], Feature->Params[PicoFeatY]); } /* DummyFastMatch */
vector<Vec2> & Path::FillPoints(const Objects & objects, const View & view) { //if (m_fill_points.size() != 0) return m_fill_points; for (unsigned i = m_start; i <= m_end; ++i) { const Rect & objb = objects.bounds[i]; // find fill points Vec2 pt; // left pt = Vec2(objb.x, objb.y+objb.h/Real(2)); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // right pt = Vec2(objb.x+objb.w, objb.y+objb.h/Real(2)); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // bottom pt = Vec2(objb.x+objb.w/Real(2), objb.y+objb.h); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // top pt = Vec2(objb.x+objb.w/Real(2), objb.y); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // topleft pt = Vec2(objb.x, objb.y); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // topright pt = Vec2(objb.x+objb.w, objb.y); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // bottom left pt = Vec2(objb.x, objb.y+objb.h); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // bottom right pt = Vec2(objb.x+objb.w, objb.y); if (PointInside(objects, pt)) m_fill_points.push_back(pt); // mid pt = Vec2(objb.x+objb.w/Real(2), objb.y+objb.h/Real(2)); if (PointInside(objects, pt)) m_fill_points.push_back(pt); } // 4 extrema Vec2 pt = (m_top + m_bottom)/2; if (PointInside(objects, pt)) m_fill_points.push_back(pt); pt = (m_left + m_right)/2; if (PointInside(objects, pt)) m_fill_points.push_back(pt); pt = (m_left + m_right + m_top + m_bottom)/4; if (PointInside(objects, pt)) m_fill_points.push_back(pt); return m_fill_points; }
float3 OBB::RandomPointInside(LCG &rng) const { return PointInside(rng.Float(), rng.Float(), rng.Float()); }
float3 Capsule::RandomPointOnSurface(LCG &rng) const { return PointInside(rng.Float(), rng.Float(), 1.f); }