没有合适的资源?快使用搜索试试~ 我知道了~
三角形网格剖分程序,可以把任意平面区域剖分成三角形网格
2星 需积分: 49 32 下载量 13 浏览量
2018-11-09
09:05:04
上传
评论 5
收藏 8KB TXT 举报
温馨提示
试读
9页
三角形网格剖分程序,可以把任意平面区域剖分成三角形网格
资源推荐
资源详情
资源评论
code for isoline(C)
Well, Thanks to all you folks who replied, I now have a contour plotting
routine, that does its job fairly well. I've posted this code below. It
is not nearly runnable as other Unix programs go, but you could use it
if you need C code to start off with to do contour plotting.
It doesn't handle stuff like labelling etc. which is somewhat tricky.
Basically almost all of the respondents suggested dividing up the set of
discrete points into a set of triangles and then computing the intersection
of these rectangles with planes representing the contour levels. This way
we can process all the levels at once instead of the "crawler" type algorithms
which is what I had originally been trying to get to work.
To summarize their ideas: if P1=P[j],P2=P[i+1][j],P3=P[i+1][j+1]
and P4=P[j+1] are four points, compute an intermediate point using
an interpolation scheme (in the code below, I just use averaging, but
one could obviously use fancier schemes). If this point is P, then the
foll. four triangles are used to compute the intersections with
contour levels l_0, .. l_n: P1 P2 P, P2 P3 P, P3 P4 P, P4 P1 P.
The intersection computation is quite trivial. Once these line segments have been
computed you could smooth them in 2d (the code below doesn't).
(see Michael Aramini's earlier posting for a variation on this that uses
rectangles directly -- He also mentions that you could use the diagonal edges
between two vertices instead of computing another intermediate point, but this
method has problems).
Well, Thanks to all you folks who replied, I now have a contour plotting
routine, that does its job fairly well. I've posted this code below. It
is not nearly runnable as other Unix programs go, but you could use it
if you need C code to start off with to do contour plotting.
It doesn't handle stuff like labelling etc. which is somewhat tricky.
Basically almost all of the respondents suggested dividing up the set of
discrete points into a set of triangles and then computing the intersection
of these rectangles with planes representing the contour levels. This way
we can process all the levels at once instead of the "crawler" type algorithms
which is what I had originally been trying to get to work.
To summarize their ideas: if P1=P[j],P2=P[i+1][j],P3=P[i+1][j+1]
and P4=P[j+1] are four points, compute an intermediate point using
an interpolation scheme (in the code below, I just use averaging, but
one could obviously use fancier schemes). If this point is P, then the
foll. four triangles are used to compute the intersections with
contour levels l_0, .. l_n: P1 P2 P, P2 P3 P, P3 P4 P, P4 P1 P.
The intersection computation is quite trivial. Once these line segments have been
computed you could smooth them in 2d (the code below doesn't).
(see Michael Aramini's earlier posting for a variation on this that uses
rectangles directly -- He also mentions that you could use the diagonal edges
between two vertices instead of computing another intermediate point, but this
method has problems).
-Sundar
-----Sample Code Follows----------
/*
* If you want try using this, you probably would need to provide
* graph_set_point(), and graph_draw_line(), besides do things like
* initialize window systems and so on.
*
* Please see the code for a note about data format
*/
/* Definitions */
struct _array {
float *a_elements;
int a_rows;
int a_cols;
float *a_filler;
};
#define ELTS(a) (a->a_elements)
#define NOROWS(a) (a->a_rows)
#define NOCOLS(a) (a->a_cols)
#define NOELTS(a) (NOROWS(a) * NOCOLS(a))
#define COLUMN_VECTOR(a) (NOCOLS((a)) == 1)
#define ROW_VECTOR(a) (NOROWS((a)) == 1)
typedef struct _array *array;
typedef struct _graph *graph;
typedef struct _graph_port *graph_port;
-----Sample Code Follows----------
/*
* If you want try using this, you probably would need to provide
* graph_set_point(), and graph_draw_line(), besides do things like
* initialize window systems and so on.
*
* Please see the code for a note about data format
*/
/* Definitions */
struct _array {
float *a_elements;
int a_rows;
int a_cols;
float *a_filler;
};
#define ELTS(a) (a->a_elements)
#define NOROWS(a) (a->a_rows)
#define NOCOLS(a) (a->a_cols)
#define NOELTS(a) (NOROWS(a) * NOCOLS(a))
#define COLUMN_VECTOR(a) (NOCOLS((a)) == 1)
#define ROW_VECTOR(a) (NOROWS((a)) == 1)
typedef struct _array *array;
typedef struct _graph *graph;
typedef struct _graph_port *graph_port;
剩余8页未读,继续阅读
资源评论
- qijumou05752019-10-16再试试 不知道好用不
NHRI_yangfan
- 粉丝: 4
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功