用C++,两点描成一条线,这样的程序怎么写?那有原码?

来源:百度知道 编辑:UC知道 时间:2024/05/10 20:29:09
用C++,两点描成一条线,这样的程序怎么写?那有原码?

我写了一个函数,用C++ 属于 Windows Application (Windows 应用程序),可以实现两点描成一条线。

void DrawPoint2Point(LONG x1, LONG y1, LONG x2, LONG y2, HWND hwnd)
{
HDC hdc;

hdc = GetDC(hwnd);

MoveToEx(hdc, (int) x1, (int) y1, (LPPOINT) NULL);
LineTo(hdc, (int) x2, (int) y2);

ReleaseDC(hwnd, hdc);
}

计算机图形学里有算法

#include <stdio.h>
#include <math.h>

struct position
{
float x;
float y;
};
position start,final,P;

int flag=0;
int F=0;
unsigned int E;
float k;
int e;
FILE *fp;
int direction;
float step=0.1;
float ustep=-0.1;
float littlestep=0.01;
float ulittlestep=-0.01;

void judge_direction()
{
if(final.y - start.y > 0 && final.x - start.x > 0)
direction=1;
else if(final.y - start.y >0 && final.x - start.x <0)
direction=2;
else if(fina