C#点和直线关系程序

C#点和直线关系程序,第1张

1、根据P1、P2点求出直线方程(这个应该不用教吧?两点式代入)

2、将P3点x坐标代入方程,求出y值

3、跟原P3点的y值做比较,比之大则在线的下方,反之则在上方

提个相关扩展,你没考虑点会在直线的左右方吗?

c 画的指针式 Roma 表

#include <dosh>

#include <stdioh>

#include <mathh>

#include <graphicsh>

void drawhourbrick(int x, int y, int color, float arg);

void drawminutebrick(int x, int y, int color, float arg);

void drawsecondbrick(int x, int y, int color, float arg);

void polygon(int n, int x, int y, int r, int color, float arg, int fillstyle);

int main()

{

int GraphDriver;

int GraphMode;

float arg = 2925;

float hourarg = 0;

float minuterarg = 0;

float secondrarg = 0;

char buffer[10];

int a, b;

int x, y, r;

int h;

int xmo[12] = {1, 2, -6, -1, -1, -2, -2, -1, 0, -4, -4, -5};

int ymo[12] = {-1, -2, -1, -1, -1, -5, 2, 1, -2, -4, -4, 0};

long delay;

float degree;

struct time time, time1;

GraphDriver = DETECT;

initgraph(&GraphDriver, &GraphMode, "");

x = 300;

y = 220;

r = 200;

degree = atan(1) / 45;

polygon(8, x, y, r, 12, arg, 0);

polygon(8, x, y, r - 2, 11, arg, 0);

polygon(8, x, y, r - 4, 14, arg, 0);

setcolor(12);

/settextstyle(DEFAULT_FONT, 1, 0);/

for (a = 0; a < 12; a++)

{

sprintf(buffer, "%d", a + 1);

outtextxy(x + (r - 22) cos((a - 2) 30 degree) + xmo[a], y + (r - 22) sin((a - 2) 30 degree) + ymo[a], buffer);

}

drawhourbrick(x, y, 14, hourarg);

drawminutebrick(x, y, 9, minuterarg);

drawsecondbrick(x, y, 13, secondrarg);

while(1)

{

gettime(&time);

if (timeti_hour != time1ti_hour || timeti_min != time1ti_min || timeti_sec != time1ti_sec)

{

h = timeti_hour;

if (h > 12)

h -= 12;

drawhourbrick(x, y, 0, hourarg);

drawminutebrick(x, y, 0, minuterarg);

drawsecondbrick(x, y, 0, secondrarg);

hourarg = (h % 12) 30 + timeti_min 05 + timeti_sec 01 / 60;

minuterarg = timeti_min 6 + timeti_sec 01;

secondrarg = timeti_sec 6;

setcolor(8);

outtextxy(x - 15, y + 120, "Roma");

drawhourbrick(x, y, 14, hourarg);

drawminutebrick(x, y, 9, minuterarg);

drawsecondbrick(x, y, 13, secondrarg);

time1 = time;

}

while(kbhit())

{

a = getch();

if (a == 27)

{

closegraph();

return 0;

}

}

}

}

void polygon(int n, int x, int y, int r, int color, float arg, int fillstyle)

{

double pi;

int i;

float x1[9], y1[9];

setcolor(color);

pi = atan(1) 4;

arg = atan(1) / 45 arg;

x1[1] = x + r cos(2 pi / n + arg);

y1[1] = y + r sin(2 pi / n + arg);

moveto(x1[1], y1[1]);

for (i = 2; i <= n; i++)

{

x1[i] = x + r cos(2 pi i / n + arg);

y1[i] = y + r sin(2 pi i / n + arg);

lineto(x1[i], y1[i]);

}

lineto(x1[1], y1[1]);

if (fillstyle != 0)

{

setfillstyle(SOLID_FILL, color);

floodfill(x, y, color);

}

}

void drawhourbrick(int x, int y, int color, float arg)

{

double pi;

int i;

float x1[4], y1[4];

setcolor(color);

pi = atan(1) / 45;

x1[0] = x;

y1[0] = y;

x1[1] = x + 20 cos(pi (arg - 90 - 23));

y1[1] = y + 20 sin(pi (arg - 90 - 23));

x1[2] = x + 25 cos(pi (arg - 90 + 23));

y1[2] = y + 25 sin(pi (arg - 90 + 23));

x1[3] = x + 120 cos(pi (arg - 90 + 0));

y1[3] = y + 120 sin(pi (arg - 90 + 0));

moveto(x1[1], y1[1]);

lineto(x1[0], y1[0]);

lineto(x1[2], y1[2]);

lineto(x1[3], y1[3]);

lineto(x1[1], y1[1]);

setfillstyle(SOLID_FILL, color);

/

floodfill((x1[0] + x1[3]) / 2, (y1[0] + y1[3]) / 2, color);

/

}

void drawminutebrick(int x, int y, int color, float arg)

{

double pi;

int i;

float x1[4], y1[4];

setcolor(color);

pi = atan(1) / 45;

x1[0] = x;

y1[0] = y;

x1[1] = x + 20 cos(pi (arg - 90 - 23));

y1[1] = y + 20 sin(pi (arg - 90 - 23));

x1[2] = x + 25 cos(pi (arg - 90 + 23));

y1[2] = y + 25 sin(pi (arg - 90 + 23));

x1[3] = x + 160 cos(pi (arg - 90 + 0));

y1[3] = y + 160 sin(pi (arg - 90 + 0));

moveto(x1[1], y1[1]);

lineto(x1[0], y1[0]);

lineto(x1[2], y1[2]);

lineto(x1[3], y1[3]);

lineto(x1[1], y1[1]);

setfillstyle(SOLID_FILL, color);

/

floodfill((x1[0] + x1[3]) / 2, (y1[0] + y1[3]) / 2, color);

/

}

void drawsecondbrick(int x, int y, int color, float arg)

{

double pi;

int i;

float x1[4], y1[4];

setcolor(color);

pi = atan(1) / 45;

x1[0] = x;

y1[0] = y;

x1[1] = x + 20 cos(pi (arg - 90 - 6));

y1[1] = y + 20 sin(pi (arg - 90 - 6));

x1[2] = x + 25 cos(pi (arg - 90 + 6));

y1[2] = y + 25 sin(pi (arg - 90 + 6));

x1[3] = x + 160 cos(pi (arg - 90 + 0));

y1[3] = y + 160 sin(pi (arg - 90 + 0));

moveto(x1[1], y1[1]);

lineto(x1[0], y1[0]);

lineto(x1[2], y1[2]);

lineto(x1[3], y1[3]);

lineto(x1[1], y1[1]);

setfillstyle(SOLID_FILL, color);

/

floodfill((x1[0] + x1[3]) / 2, (y1[0] + y1[3]) / 2, color);

/

}

曲线要素值 交 点 号 1 起点 1 2 3交点坐标 交点桩号 x 2 0 17575 391220628 #DIV/0! 3 y 4 度° 5 分′ 6秒″ 7 弧度 8 9 转角 半径 缓和曲 线长度 L1 10 缓和曲 线长度 L2 11 △R q 切线长度 切线长度 曲线长度 T! T2 14 15 16 外距 校正值 第一缓和 曲线起点 19

以上就是关于C#点和直线关系程序全部的内容,包括:C#点和直线关系程序、C语言画直线和填充的程序,要有算法的、5800计算器怎么输入计算直线、曲线及转角表坐标计算程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10098516.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存