Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Martin's srpg polygon generator

License

NotificationsYou must be signed in to change notification settings

cgalab/genpoly-srpg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The code srpg generates simply-connected and multiply-connected polygons bymeans of a regular grid (with quadratic cells).

Any standard C compiler will do. E.g.:

gcc -O2 -Wall -o srpg srpg.c

This is also basically what the Makefile does, so you could also just runmake.

Usage

srgp --Nx <X> --Ny <Y> --output <OUTPUTFILE>     [--percent <P>] [--seed <S>] [--holes]     [--aligned | --perturb [--smooth <M>]]     [--hierarchy <N>] [--diagonal]

where X,Y,M,N are positive integers, S is a non-negative integer,0.001 < P < 0.5 is a real, and OUTPUTFILE is the name of the output file.

Generating polygonal data

The computation is based on a grid with X times Y quadratic cells. The userhas to specify X and Y. In addition, the user has to specify the name of anoutput file. If no other options are specified, then srpg generates a polygonwhose edges are parallel to the coordinate axes. The number of vertices of thepolygon generated is random, but it does depend on X, Y and the percentage P:The larger X and Y, the more vertices the polygon tends to have if P is keptconstant. Visually pleasing "random" polygons can be achieved by selectingfairly small values for P, e.g., P:=0.1 or even P:=0.01. (However, a smallvalue of P will also reduce the number of vertices of the polygon.)

The option "--aligned" will cause all vertices to lie on grid points, i.e., tohave integer coordinates. The option "--diagonal" causes srpg to cut off somecorners by line segments with inclination +/-1, thus generating an octagonalpolygon. If the option "--perturb" is used then the vertices are moved awayfrom the grid points and (most) polygon edges will not be parallel to thecoordinate axes. The option "--hierarchy N" instructs srpg to apply N roundsof a recursive refinement to the polygon generated. (Typically, N will be asmall positive integer.) If the option "--holes" is specified then srpg willgenerate a multiply-connected polygonal area. The option "--smooth M" tellssrpg to apply M rounds of corner cutting to the polygon generated, thusgenerating a polygon which resembles a polygonal approximation of a smoothfree-form curve. (Again, M will be a small positive integer.)

Please direct bug reports or suggestions to Martin Held atheld@cs.sbg.ac.at.

License

This is free software. You may redistribute it and/or modifyit under the terms of the GNU General Public License (v3).

About

Martin's srpg polygon generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp