//============================================================================= Point2F Rectangle2::center() const { Point2F result; Vector2F dir2 = dir(); dir2.multiply(0.5); result.add(dir2); Vector2F up2 = up(); up2.multiply(0.5); result.add(up2); return result; }
//============================================================================= Point2F Ray2::getPoint(double parameter, double offset) const { Vector2F delta = dir_; delta.multiply(parameter); Point2F result = origin_; result.add(delta); if (offset == 0.0) return result; Vector2F offsetVec = dir_; offsetVec.setPerpendLeft(); offsetVec.multiply( offset/offsetVec.getLength() ); result.add(offsetVec); return result; }
//============================================================================= Point2F Rectangle2::point(int index) const { while ( index < 0 ) index += 4; while ( index > 3 ) index -= 4; Point2F result = origin_; switch (index) { case 1: result.add(width_); break; case 2: result.add(width_); case 3: result.add(up_()); break; case 0: default: break; } return result; }