- 1、本文档共7页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
计算机图形学 直线裁剪代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace LineCut_Cohen
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//定义钻石参数
int x0 = 100;
int y0 = 100;
int n = 13;
int r = 50;
int[] x;
int[] y;
//
//计算钻石顶点 by tiantian
//
public void ZuanShi()
{
float t = (float)3.14159 * 2 / n;
x = new int[n];
y = new int[n];
for (int i = 0; i n; i++)
{
x[i] = (int)(r * Math.Cos(i * t) + x0);
y[i] = (int)(r * Math.Sin(i * t) + y0);
}
}
//
//计算点(x,y)的编码
//
void CompOutCode(int x, int y, Rectangle rect, OutCode outCode)
{
outCode.all = 0;
outCode.top = outCode.bottom = 0;
if (y rect.Top) //rect类的top相当于我们惯常用的坐标系的bottom by:tiantian
{
outCode.bottom = 1;
outCode.all += 1;
}
else if (y rect.Bottom)//rect类的bottom相当于我们惯常用的坐标系的top by:tiantian
{
outCode.top = 1;
outCode.all += 1;
}
outCode.right = outCode.left = 0;
if (x rect.Right)
{
outCode.right = 1;
outCode.all += 1;
}
else if (x rect.Left)
{
outCode.left = 1;
outCode.all += 1;
}
}
//
//线段裁剪,p0(x0,y0),p1(x1,y1)为待裁剪线断,rect为裁剪窗口
//
bool ChoenSutherlandLineClip(ref int x0, ref int y0, ref int x1, ref int y1, Rectangle rect) //这里必须是引用传递!by:tiantian
{
Boolean accept, done;
OutCode outCode0 = new OutCode();
OutCode
文档评论(0)