int main() { __CPROVER_ASYNC_0: P0(0); __CPROVER_ASYNC_1: P1(0); __CPROVER_ASYNC_2: P2(0); __CPROVER_assume(__unbuffered_cnt==3); fence(); // EXPECT:exists __CPROVER_assert(!(__unbuffered_p1_r1==1 && __unbuffered_p2_r1==1 && __unbuffered_p2_r3==0), "Program was expected to be safe for PPC, model checker should have said NO.\nThis likely is a bug in the tool chain."); return 0; }
int main() { Bitmap bitmap(640, 480); Camera cam; cam.zoom = 1, cam.focus = 10000, cam.height = 100; BezObj teapot(INPUT); teapot.move(P3(0, -100, -1000)); teapot.rotateZ(-45); teapot.rotateX(-45); teapot.split(2); cam.shot(teapot, bitmap); ImageProcessor ip(&bitmap); ip.rerange( P2(-320, -240), P2(0, 0) ); ip.GaussianBlur(2); bitmap.save(OUTPUT); system(OUTPUT); return 0; }
int main() { __CPROVER_ASYNC_0: P0(0); __CPROVER_ASYNC_1: P1(0); __CPROVER_ASYNC_2: P2(0); __CPROVER_assume(__unbuffered_cnt==3); fence(); // EXPECT:exists __CPROVER_assert(!(z==2 && __unbuffered_p1_r1==1 && __unbuffered_p2_r1==1), "Program proven to be relaxed for PPC, model checker says YES."); return 0; }
AREXPORT ArMapObject::ArMapObject(const char *type, ArPose pose, const char *description, const char *iconName, const char *name, bool hasFromTo, ArPose fromPose, ArPose toPose) : myType((type != NULL) ? type : ""), myBaseType(), myName((name != NULL) ? name : "" ), myDescription((description != NULL) ? description : "" ), myPose(pose), myIconName((iconName != NULL) ? iconName : "" ), myHasFromTo(hasFromTo), myFromPose(fromPose), myToPose(toPose), myFromToSegments(), myStringRepresentation() { if (myHasFromTo) { double angle = myPose.getTh(); double sa = ArMath::sin(angle); double ca = ArMath::cos(angle); double fx = fromPose.getX(); double fy = fromPose.getY(); double tx = toPose.getX(); double ty = toPose.getY(); ArPose P0((fx*ca - fy*sa), (fx*sa + fy*ca)); ArPose P1((tx*ca - fy*sa), (tx*sa + fy*ca)); ArPose P2((tx*ca - ty*sa), (tx*sa + ty*ca)); ArPose P3((fx*ca - ty*sa), (fx*sa + ty*ca)); myFromToSegments.push_back(ArLineSegment(P0, P1)); myFromToSegments.push_back(ArLineSegment(P1, P2)); myFromToSegments.push_back(ArLineSegment(P2, P3)); myFromToSegments.push_back(ArLineSegment(P3, P0)); myFromToSegment.newEndPoints(fromPose, toPose); } else { // pose size_t whPos = myType.rfind("WithHeading"); size_t whLen = 11; if (whPos > 0) { if (whPos == myType.size() - whLen) { myBaseType = myType.substr(0, whPos); } } } // end else pose IFDEBUG( ArLog::log(ArLog::Normal, "ArMapObject::ctor() created %s (%s)", myName.c_str(), myType.c_str()); );
void FillRectangle( const DrawUtils::DrawInfos& i, Pixel& P ) { float Alpha = i.Coverage; float Distance = 1.0f - 2.0f * abs(i.Distance); Pixel P2( NjFloat4( Distance, 0, 0, 0 ) ); // Draw distance to border in red if ( Distance < 0.0f ) Alpha = 0.0f; P.Blend( P2, Alpha ); }
double t_pair_PH(double E, Particle& particle, Fun* tpf) //E=Ep { DataInjection data; data.E = E; data.mass = particle.mass; data.tpf = tpf; double mass = particle.mass; double cte = 0.5*P2(mass*cLight2)*cLight; double b = 10*targetPhotonEmax; //energia maxima de los fotones en erg double a1 = mass*P2(cLight)*pairThresholdPH/(2*E); double a = std::max(a1,targetPhotonEmin); double integral = RungeKutta(a,b,&cPairPH,&dPH,&f_t_PHPair,&data); return cte*integral/P2(E); }
int main() { __CPROVER_ASYNC_0: P0(0); __CPROVER_ASYNC_1: P1(0); __CPROVER_ASYNC_2: P2(0); __CPROVER_ASYNC_3: P3(0); __CPROVER_assume(__unbuffered_cnt==4); fence(); // EXPECT:exists __CPROVER_assert(!(x==2 && z==2 && __unbuffered_p1_EAX==0 && __unbuffered_p3_EAX==2 && __unbuffered_p3_EBX==0), "Program proven to be relaxed for X86, model checker says YES."); return 0; }
inline void AbstractPath::filterOffset(const int i, Vec2f& here) const { Vec2f P1(getElement(i-1), getElement(i)); Vec2f P2(getElement(i+1), getElement(i)); float p1len = P1.Len(), p2len = P2.Len(), sum = p1len+p2len; P1 *= p2len / sum; P2 *= p1len / sum; here = P1; here += P2; }
maxint_t P2(maxint_t x, int threads) { if (x < 1) return 0; double alpha = get_alpha_deleglise_rivat(x); string limit = get_max_x(alpha); if (x > to_maxint(limit)) throw primecount_error("P2(x): x must be <= " + limit); if (is_print()) set_print_variables(true); int64_t y = (int64_t) (iroot<3>(x) * alpha); if (x <= numeric_limits<int64_t>::max()) return P2((int64_t) x, y, threads); else return P2(x, y, threads); }
std::vector<sf::Vector2f> _getEdges(TPPLPoly& A) { std::vector<sf::Vector2f> edges; for(unsigned int i=0; i < (A.GetNumPoints()+1) ; ++i) { sf::Vector2f P1( A[i].x, A[i].y); sf::Vector2f P2( A[(i+1)%A.GetNumPoints()].x, A[(i+1)%A.GetNumPoints()].y ); edges.push_back( P2 - P1 ); } return edges; }
Eigen::MatrixXd ptcloudFromCorrespondences(const std::string& correspondencesFilename, const std::string& extrinsicsFilename, const std::string& ptcloudFilename) { // THE UNDISTORTED POINTS (calibrated by K in P1, P2) std::ifstream in1(correspondencesFilename); if (in1.bad()) return Eigen::MatrixXd(1,3); unsigned int N = 0; char buf[256]; for (; in1.good(); N++) in1.getline(buf, 256); N--; // Advanced past for loop in1.close(); std::ifstream in(correspondencesFilename); if (in.bad()) return Eigen::MatrixXd(1, 3); char c; std::vector< cv::Point2d > x1v, x2v; for (unsigned int i = 0; i < N && !in.bad(); i++) { double x1x, x1y, x2x, x2y, max, qwx, qwy; in >> x1x >> c >> x1y >> c >> x2x >> c >> x2y >> c >> max >> c >> qwx >> c >> qwy; // Hardcoded threshold of .6, qw > .5 if ((max > .6))// && (qwx > .5) && (qwy > .5)) // if stabilization { x1v.push_back(cv::Point2d(x1x, x1y)); x2v.push_back(cv::Point2d(x2x, x2y)); } } Eigen::MatrixXd x1(2, x1v.size()); Eigen::MatrixXd x2(2, x2v.size()); unsigned int co = 0; for (std::vector<cv::Point2d>::iterator x1r = x1v.begin(), x2r = x2v.begin(); ((x1r != x1v.end()) && (x2r != x2v.end())); x1r++, x2r++, co++) { x1(0, co) = x1r->x; x1(1, co) = x1r->y; x2(0, co) = x2r->x; x2(1, co) = x2r->y; } Eigen::MatrixXd P1 = Eigen::MatrixXd::Identity(3, 4), P2 = Eigen::MatrixXd::Identity(3, 4); P2(0, 3) = 1.0; if (extrinsicsFilename != "") { std::ifstream extrinsicsFile(extrinsicsFilename); if (extrinsicsFile.bad()) return Eigen::MatrixXd(1, 3); double rx, ry, rz, tx, ty, tz; extrinsicsFile >> rx >> c >> ry >> c >> rz >> c; extrinsicsFile >> tx >> c >> ty >> c >> tz >> c; std::cout << "Getting extrinsics: " << rx << ',' << ry << ',' << rz << ',' << tx << ',' << ty << ',' << tz << std::endl; P2 = cameraMatrixKnownRT(rx, ry, rz, tx, ty, tz); }
bool Bitmap::setSize(int width, int height) { if(buffer) delete [] buffer; this->width = width; this->height = height; if(width * height > 2073600) return false; bitmapHeaderInit(header, width, height); buffer = new RGB[width * height]; setOrigin(P2(width / 2 - 1, height / 2 - 1)); return true; }
void test_Bbox_E3_operator_incr() { Point_E3d P1(-5,-4,-3); Point_E3d P2( 7, 6, 5); Bbox_E3d box(P1); box += P2; assert( box == Bbox_E3d(P1, P2) ); assert( box.center() == Point_E3d(1,1,1) ); }
bool CSPrimBox::Write2XML(TiXmlElement &elem, bool parameterised) { CSPrimitives::Write2XML(elem,parameterised); TiXmlElement P1("P1"); m_Coords[0].Write2XML(&P1,parameterised); elem.InsertEndChild(P1); TiXmlElement P2("P2"); m_Coords[1].Write2XML(&P2,parameterised); elem.InsertEndChild(P2); return true; }
int main() { GlobalPoint P1(3., 4., 7.); GlobalPoint P2(-2., 5., 7.); oldCode(P1,P2); newCode(P1,P2); oldCode(P2,P1); newCode(P2,P1); return 0; }
void test_mixed_of() { typedef boost::geometry::model::polygon<P1> polygon_type1; typedef boost::geometry::model::polygon<P2> polygon_type2; typedef boost::geometry::model::box<P1> box_type1; typedef boost::geometry::model::box<P2> box_type2; polygon_type1 poly1, poly2; boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1); boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2); box_type1 box1(P1(1, 1), P1(4, 4)); box_type2 box2(P2(0, 0), P2(5, 5)); P1 p1(3, 3); P2 p2(3, 3); BOOST_CHECK_EQUAL(bg::covered_by(p1, poly2), true); BOOST_CHECK_EQUAL(bg::covered_by(p2, poly1), true); BOOST_CHECK_EQUAL(bg::covered_by(p2, box1), true); BOOST_CHECK_EQUAL(bg::covered_by(p1, box2), true); BOOST_CHECK_EQUAL(bg::covered_by(box1, box2), true); BOOST_CHECK_EQUAL(bg::covered_by(box2, box1), false); }
void Bitmap::sTriangle(P2 p1, P2 p2, P2 p3) { double area2o = fabs(det(p3 - p1, p2 - p1)); for(int i = 0 - int(origin.x); i < width - int(origin.x); i++) { for(int j = 0 - int(origin.y); j < height - int(origin.y); j++) { double area2n = 0.0; area2n += fabs(det(P2(i, j) - p1, P2(i, j) - p2)); area2n += fabs(det(P2(i, j) - p2, P2(i, j) - p3)); area2n += fabs(det(P2(i, j) - p3, P2(i, j) - p1)); if(area2n <= area2o) set(P2(i, j)); } } }
void test_op() { Point_E3d P1(3.0,4.0,5.0); Point_E3d P2(4.0,7.0,9.0); Vector_E3d V1(8.0,4.0,2.0); Point_E3d A1 = P1; A1 += V1; assert( Point_E3d(11.0,8.0,7.0) == A1 ); A1 -= V1; assert( P1 == A1 ); Vector_E3d V2(P1, P2); assert( Vector_E3d(1.0, 3.0, 4.0) == V2 ); }
QPolygon KDChart::TextLayoutItem::rotatedCorners() const { // the angle in rad const qreal angle = mAttributes.rotation() * PI / 180.0; QSize size = unrotatedSizeHint(); // my P1 - P4 (the four points of the rotated area) QPointF P1( size.height() * sin( angle ), 0 ); QPointF P2( size.height() * sin( angle ) + size.width() * cos( angle ), size.width() * sin( angle ) ); QPointF P3( size.width() * cos( angle ), size.width() * sin( angle ) + size.height() * cos( angle ) ); QPointF P4( 0, size.height() * cos( angle ) ); QPolygon result; result << P1.toPoint() << P2.toPoint() << P3.toPoint() << P4.toPoint(); return result; }
Point Rectangle::Sample(float u, float v, Normal *Ns) const { // u and v are random samples on the surface of the light source Point P0(-x/2, y/2, height), P1(x/2, y/2, height); Point P2(-x/2, -y/2, height), P3(x/2, -y/2, height); Point p = P0 + (P1 - P0) * u + (P2 - P0) * v; Normal n = Normal(Cross(P2-P0, P1-P0)); *Ns = Normalize(n); // NORMAL ON THE PLANE *Ns = Normalize((*ObjectToWorld)(n)); if (ReverseOrientation) *Ns *= -1.f; return (*ObjectToWorld)(p); }
int256_t P2(int128_t x, int threads) { if (x < 1) return 0; double alpha = get_alpha_deleglise_rivat(x); string limit = get_max_x(alpha); if (x > to_int128(limit)) throw primesum_error("P2(x): x must be <= " + limit); if (is_print()) set_print_variables(true); int64_t y = (int64_t) (iroot<3>(x) * alpha); return P2(x, y, threads); }
void srTSpherMirror::SetupInAndOutPlanes(TVector3d* InPlane, TVector3d* OutPlane) {// Assumes InPlaneNorm and transverse part InPlaneCenPo already defined !!! TVector3d &InPlaneCenPo = *InPlane, &InPlaneNorm = InPlane[1]; TVector3d &OutPlaneCenPo = *OutPlane, &OutPlaneNorm = OutPlane[1]; TVector3d LocInPlaneNorm = InPlaneNorm; FromLabToLocFrame_Vector(LocInPlaneNorm); double xP = -0.5*Dx, yP = -0.5*Dy; TVector3d P0(xP, yP, SurfaceFunction(xP, yP, 0)); TVector3d P1(-xP, yP, SurfaceFunction(-xP, yP, 0)); TVector3d P2(xP, -yP, SurfaceFunction(xP, -yP, 0)); TVector3d P3(-xP, -yP, SurfaceFunction(-xP, -yP, 0)); TVector3d EdgePoints[] = { P0, P1, P2, P3 }; int LowestInd, UppestInd; FindLowestAndUppestPoints(LocInPlaneNorm, EdgePoints, 4, LowestInd, UppestInd); TVector3d PointForInPlane = EdgePoints[LowestInd]; FromLocToLabFrame_Point(PointForInPlane); InPlaneCenPo.y = PointForInPlane.y; TVector3d LocInPlaneCenPo = InPlaneCenPo; FromLabToLocFrame_Point(LocInPlaneCenPo); TVector3d LocInPlane[] = { LocInPlaneCenPo, LocInPlaneNorm }; TVector3d LocP, LocN; FindRayIntersectWithSurface(LocInPlane, 0, LocP); SurfaceNormalAtPoint(LocP.x, LocP.y, 0, LocN); TVector3d LocOutPlaneNorm = LocInPlaneNorm; ReflectVect(LocN, LocOutPlaneNorm); FindLowestAndUppestPoints(LocOutPlaneNorm, EdgePoints, 4, LowestInd, UppestInd); OutPlaneCenPo = (EdgePoints[UppestInd]*LocOutPlaneNorm)*LocOutPlaneNorm; *OutPlaneInLocFrame = OutPlaneCenPo; OutPlaneInLocFrame[1] = LocOutPlaneNorm; FromLocToLabFrame_Point(OutPlaneCenPo); OutPlaneNorm = LocOutPlaneNorm; FromLocToLabFrame_Vector(OutPlaneNorm); TVector3d LabN = LocN; FromLocToLabFrame_Vector(LabN); ExRefInLabFrameBeforeProp = TVector3d(1.,0.,0.); ReflectVect(LabN, ExRefInLabFrameBeforeProp); EzRefInLabFrameBeforeProp = TVector3d(0.,0.,1.); ReflectVect(LabN, EzRefInLabFrameBeforeProp); }
int sc_main( int, char*[] ) { sc_signal<int> ack; sc_signal<int> ready; ack = 1; ready = 1; sc_clock clk( "Clock", 20, SC_NS, 0.5, 0.0, SC_NS ); proc1 P1( "P1", clk, ack, ready ); proc2 P2( "P2", clk, ready, ack ); sc_start( 500, SC_NS ); return 0; }
int main(){ int a,b; Point P1; scanf("%d%d",&a,&b); Point P2(a,b); scanf("%d%d",&a,&b); Point P3(a,b); if (P1.IsOrigin()) printf("P1 origin\n"); else printf("P1 bukan origin\n"); if (P2.IsOrigin()) printf("P2 origin\n"); else printf("P2 bukan origin\n"); if (P3.IsOrigin()) printf("P3 origin\n"); else printf("P3 bukan origin\n"); Point P4 = P1.Add(P2,P3); Point P5 = P2.Add(P3); if (P2.IsEqual(P5)) printf("P2 equal P5\n"); else printf("P2 not equal P5\n"); if (P4.IsEqual(P5)) printf("P4 equal P5\n"); else printf("P4 not equal P5\n"); scanf("%d%d",&a,&b); Point P6 = P2.Add(a,b); scanf("%d%d",&a,&b); Point P7 = P3.Add(a,b); P4.AddToMe(P2); scanf("%d%d",&a,&b); P5.AddToMe(a,b); printf("Kuadran P2 : %d\n",P2.Kuadran()); printf("Kuadran P3 : %d\n",P3.Kuadran()); printf("Kuadran P6 : %d\n",P6.Kuadran()); printf("Kuadran P7 : %d\n",P7.Kuadran()); printf("P2 : "); PrintPoint(P2); printf("P3 : "); PrintPoint(P3); printf("P4 : "); PrintPoint(P4); printf("P5 : "); PrintPoint(P5); printf("P6 : "); PrintPoint(P6); printf("P7 : "); PrintPoint(P7); return 0; }
int main() { GlobalPoint P1(3., 4., 7.); GlobalPoint P2(-2., 5., 7.); oldCode(P1,P2); newCode(P1,P2); oldCode(P2,P1); newCode(P2,P1); { ThirdHitPredictionFromInvParabola pred(P1,P2,0.2,0.05,0.1); std::cout << "ip min, max " << pred.theIpRangePlus.min() << " " << pred.theIpRangePlus.max() << " " << pred.theIpRangeMinus.min() << " " << pred.theIpRangeMinus.max() << std::endl; std::cout << "A,B +pos " << pred.coeffA(0.1) << " " << pred.coeffB(0.1) << std::endl; std::cout << "A,B -pos " << pred.coeffA(-0.1) << " " << pred.coeffB(-0.1) << std::endl; auto rp = pred.rangeRPhi(5.,1); auto rn = pred.rangeRPhi(5.,-1); std::cout << "range " << rp.min() << " " << rp.max() << " " << rn.min() << " " << rn.max() << std::endl; } ThirdHitPredictionFromInvParabola pred(-1.092805, 4.187564, -2.361283, 7.892722, 0.111413, 0.019043, 0.032000); std::cout << "ip min, max " << pred.theIpRangePlus.min() << " " << pred.theIpRangePlus.max() << " " << pred.theIpRangeMinus.min() << " " << pred.theIpRangeMinus.max() << std::endl; { auto rp = pred.rangeRPhi(11.4356,1); auto rn = pred.rangeRPhi(11.4356,-1); std::cout << "range " << rp.min() << " " << rp.max() << " " << rn.min() << " " << rn.max() << std::endl; } { auto rp = pred.rangeRPhi(13.2131,1); auto rn = pred.rangeRPhi(13.2131,-1); std::cout << "range " << rp.min() << " " << rp.max() << " " << rn.min() << " " << rn.max() << std::endl; } return 0; }
AREXPORT void ArForbiddenRangeDevice::processMap(void) { std::list<ArMapObject *>::const_iterator it; ArMapObject *obj; myDataMutex.lock(); ArUtil::deleteSet(mySegments.begin(), mySegments.end()); mySegments.clear(); for (it = myMap->getMapObjects()->begin(); it != myMap->getMapObjects()->end(); it++) { obj = (*it); if (strcmp(obj->getType(), "ForbiddenLine") == 0 && obj->hasFromTo()) { mySegments.push_back(new ArLineSegment(obj->getFromPose(), obj->getToPose())); } if (strcmp(obj->getType(), "ForbiddenArea") == 0 && obj->hasFromTo()) { double angle = obj->getPose().getTh(); double sa = ArMath::sin(angle); double ca = ArMath::cos(angle); double fx = obj->getFromPose().getX(); double fy = obj->getFromPose().getY(); double tx = obj->getToPose().getX(); double ty = obj->getToPose().getY(); ArPose P0((fx*ca - fy*sa), (fx*sa + fy*ca)); ArPose P1((tx*ca - fy*sa), (tx*sa + fy*ca)); ArPose P2((tx*ca - ty*sa), (tx*sa + ty*ca)); ArPose P3((fx*ca - ty*sa), (fx*sa + ty*ca)); mySegments.push_back(new ArLineSegment(P0, P1)); mySegments.push_back(new ArLineSegment(P1, P2)); mySegments.push_back(new ArLineSegment(P2, P3)); mySegments.push_back(new ArLineSegment(P3, P0)); } } myDataMutex.unlock(); }
void create_map(int W, int H){ int y,x; pixel_map.H=H; pixel_map.W=W; pixel_map.map = (point**)malloc(sizeof(point*)*H); //Tellin mälu mapi kõrguse jaoks (Y koord.) for(y=0; y<H;y++){ pixel_map.map[y] = (point*)malloc(sizeof(point)*W); //Tellin mälu mapi ühe rea jaoks (x koord.) for(x=0;x<W;x++){ point p=P2(x,y); //Leian vaste sisendpildil väljundi x ja y koordinaadile pixel_map.map[y][x].x=p.x; //Lisan mapi aadressile (x,y) punkti p, mis -> sisendpildi punktile p' pixel_map.map[y][x].y=p.y; } } return; }
BOOL KG3DTerrainRoad::CheckIncurvate(KG3DTerrainRoadPassage::TinyLine& L1,KG3DTerrainRoadPassage::TinyLine& L2) { if((L1.vLeft2D == L2.vLeft2D)||(L1.vLeft2D == -L2.vLeft2D)) return FALSE; D3DXVECTOR2 P1(L1.vPositionA[0].x,L1.vPositionA[0].z); D3DXVECTOR2 P2(L2.vPositionA[0].x,L2.vPositionA[0].z); float K1 = L1.vLeft2D.y/L1.vLeft2D.x; float K2 = L2.vLeft2D.y/L2.vLeft2D.x; D3DXVECTOR2 Inter; Inter.x = (P2.y - P1.y + K1 * P1.x - K2 * P2.x)/(K1 - K2); Inter.y = K1 * (Inter.x - P1.x) + P1.y; D3DXVECTOR2 dir = Inter - P1; if( dir.x * L2.vLeft2D.x >= 0 && dir.y * L2.vLeft2D.y >= 0) return TRUE; return FALSE; }
void DrawVisibility(QPainter *p,pigalePaint *paint) {TopologicalGraph G(paint->GCP); Prop<Tpoint> P1(G.Set(tedge()),PROP_DRAW_POINT_1); Prop<Tpoint> P2(G.Set(tedge()),PROP_DRAW_POINT_2); Prop<int> x1(G.Set(tvertex()),PROP_DRAW_INT_1); Prop<int> x2(G.Set(tvertex()),PROP_DRAW_INT_2); Prop<int> y(G.Set(tvertex()),PROP_DRAW_INT_5); Prop<short> ecolor(G.Set(tedge()),PROP_COLOR); Prop<short> vcolor(G.Set(tvertex()),PROP_COLOR); double alpha=0.35; p->setFont(QFont("sans",Min((int)(1.8*alpha * Min(paint->xscale,paint->yscale) + .5),13))); Tpoint a,b; for(tvertex v=1;v<=G.nv();v++) paint->DrawText(p,x1[v]-alpha,y[v]+alpha, x2[v]-x1[v]+2*alpha,2*alpha,v,vcolor[v]); for (tedge e = 1;e <= G.ne();e++) {a.x() = P1[e].x(); a.y() = P1[e].y() + alpha; b.x() = P1[e].x(); b.y() = P2[e].y() - alpha; paint->DrawSeg(p,a,b,ecolor[e]); } }
void Bitmap::line(P2 p1, P2 p2, RGB c) { double dx = p2.x - p1.x, dy = p2.y - p1.y; if(dx == 0 || dy == 0) { if(dx != 0) { if(dx > 0) for(int i=p1.x; i<=p2.x; i++) set(P2(double(i), p1.y), c); else if(dx < 0) for(int i=p1.x; i>=p2.x; i--) set(P2(double(i), p1.y), c); } else if(dy != 0) { if(dy > 0) for(int j=p1.y; j<=p2.y; j++) set(P2(p1.x, double(j)), c); else if(dy < 0) for(int j=p1.y; j>=p2.y; j--) set(P2(p1.x, double(j)), c); } else set(p1, color); } else { if(abs(dx) >= abs(dy)) { if(dx > 0) for(int i=p1.x; i<=p2.x; i++) set(P2(double(i), p1.y + (dy * (double(i) - p1.x)) / dx), c); else if(dx < 0) for(int i=p1.x; i>=p2.x; i--) set(P2(double(i), p1.y + (dy * (double(i) - p1.x)) / dx), c); } else { if(dy > 0) for(int j=p1.y; j<=p2.y; j++) set(P2(p1.x + (dx * (double(j) - p1.y)) / dy, double(j)), c); else if(dy < 0) for(int j=p1.y; j>=p2.y; j--) set(P2(p1.x + (dx * (double(j) - p1.y)) / dy, double(j)), c); } } }