资源简介
计算机图形学的作业;完成度非常高;有需要的可以下载
代码片段和文件信息
package DrawShape;
import java.util.ArrayList;
public class GCUtil {
// private static int p0 = 0;
// private static int x0 = 0;
// private static int y0 = 0;
// private static int pk = 0;
// private static int pk1 = 0;
// private static boolean s = false;
private GCUtil(){}
public static thePoint[] DDAMethod (int a1int a2int b1int b2)//dda算法实例
{
int step;
int dx = b1 - a1;
int dy = b2 - a2;
thePoint[] p = new thePoint[800];
float xIncrementyIncrementx y;
Mainframe.c = 0;
x = a1;
y = a2;
if(Math.abs(dx) > Math.abs(dy))
step = Math.abs(dx);
else
step = Math.abs(dy);
xIncrement=(float)(dx)/(float)(step);
yIncrement = (float)(dy)/(float)(step);
p[0] = new thePoint();
p[0].setThePoint(Math.round(x) Math.round(y));
Mainframe.c = Mainframe.c + 1;
for(int i = 1; i < step; i++)
{
x = x + xIncrement;
y = y + yIncrement;
p[i] = new thePoint();
p[i].setThePoint(Math.round(x)Math.round(y));
// System.out.println(“x 和 y: “+ x + “ “ + y);
Mainframe.c = Mainframe.c + 1;
}
// System.out.println(xIncrement);
return p;
}
public static thePoint[] BMethod (int a1int a2int b1int b2)//Bresenham算法
{
thePoint[] p = new thePoint[800];
int dx =Math.abs(b1 - a1);
int dy =Math.abs(b2 - a2);
int p0x =2 * dy - dx;
int p0y =2 * dx - dy;
int twody = 2 * dy;
int twodx = 2 * dx;
int twodxy = 2 * dy - 2 * dx;
int twodyx = 2 * dx - 2 * dy;
int x = 0y = 0;
int t = 0t1 = 0; //确定每次随着单位量的变化,另一个变量是增加还是减少;
Mainframe.c = 0;
p[0] = new thePoint();
Mainframe.c = Mainframe.c + 1;
if (dx > dy)
{
t = a1 < b1 ? 1 : -1;
t1 = a2 < b2 ? 1: -1;/////
x = a1; y = a2;
p[0].setThePoint(x y);
//System.out.println(“x 和 y: “+ x + “ “ + y);
int i = 0;
while(x != b1)
{
i++;
x = x+t;
Mainframe.c++;
if(p0x < 0)
p0x = p0x + twody;
else
{
y = y + t1;
p0x = p0x + twodxy;
}
p[i] = new thePoint();
p[i].setThePoint(xy);
// System.out.println(“x 和 y: “+ x + “ “ + y);
}
}else
{
t = a2 < b2 ? 1 : -1;
t1 = a1 < b1 ? 1: -1;
x = a1; y = a2;
p[0].setThePoint(x y);
// System.out.println(“x 和 y: “+ x + “ “ + y);
int i = 0;
while(y != b2)
{
i++;
y = y + t;
Mainframe.c++;
if(p0y < 0)
p0y = p0y + twodx;
else
{
x = x + t1;
p0y = p0y + twodyx;
}
p[i] = new thePoint();
p[i].setThePoint(xy);
System.out.println(“x 和 y: “+ x + “ “ + y);
}
}
// System.out.println(Mainframe.c);
return p;
}
public static thePoint[] CirMethod(int r)//画圆形算法
{
thePoint[] p = new thePoint[800];
int x = 0 y=0;
x = 0; y = r;
int p0 = 1 - r;
p[0] = new thePoint();
p[0].setThePoint(x y);
Mainframe.c = 1;
int i =0;
while(x < y)
{
Mainframe.c ++;
i = i + 1;
if(p0 < 0)
{
x++;
p0 = p0 + 2*x + 1
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-10-07 20:13 图形\
文件 2875 2017-10-06 21:16 图形\.classpath
文件 382 2017-10-06 21:15 图形\.project
目录 0 2017-10-07 20:13 图形\.settings\
文件 598 2017-10-06 21:15 图形\.settings\org.eclipse.jdt.core.prefs
目录 0 2017-10-07 20:13 图形\bin\
目录 0 2017-10-07 20:13 图形\bin\DrawShape\
文件 3622 2017-10-07 19:25 图形\bin\DrawShape\GCUtil.class
文件 4355 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1036 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 2706 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 1034 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 6254 2017-10-07 19:31 图形\bin\DrawShape\Mainfr
文件 733 2017-10-07 19:25 图形\bin\DrawShape\thePoint.class
目录 0 2017-10-07 20:13 图形\src\
目录 0 2017-10-07 20:13 图形\src\DrawShape\
文件 4604 2017-10-07 19:25 图形\src\DrawShape\GCUtil.java
文件 12168 2017-10-07 19:31 图形\src\DrawShape\Mainfr
相关资源
- mysql-connector-java-5.1.18-bin.jar
- 目标代码生成 java版
- PageOffice Java 动态填充Word模版
- PageOffice Java中动态填充Word模版生成正
- 决策树ID3算法Java实现
- 会员管理系统代码java编写
- 彩色图转灰度图加权,最大值,平均
- java编写的简单通讯录使用容器类,未
- java3d设置视点的初始位置
- java里提取word里的图片
- kmeans中文文本聚类java源码包括对文本
- luajava-1.1-win32-lua51.zip
- java编写的食堂售饭系统
- 手机游戏 涂鸦跳跃 Java版
- java班级管理系统
- 基于Java的socket的网络聊天程序
- Java版超级玛丽
- 外排序之多路归并的java实现
- 带有动画的java龟兔赛跑源代码 绝多
- 贪吃蛇JAVA源代码带注解
- PL0编译器java版
- 基于java socket网络编程实现的简单模拟
- 银行项目java源码
-
ba
se64的js与java相互解密.rar - 中软国际Java程序员机试题
- kmeans聚类java实现附测试数据及结果
- java做的一个定时提醒软件
- java绘制复杂图形并输出图片
- Java贪吃蛇
- Java做的GUI的小区物业管理
评论
共有 条评论