Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
constant-workspace-algorithms-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mikadelor
constant-workspace-algorithms-c
Commits
de02a0d3
Commit
de02a0d3
authored
6 years ago
by
mika
Browse files
Options
Downloads
Patches
Plain Diff
improving circle
parent
8cde16f3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/delaunay.c
+14
-9
14 additions, 9 deletions
src/delaunay.c
src/main.c
+1
-1
1 addition, 1 deletion
src/main.c
src/voronoi.c
+2
-1
2 additions, 1 deletion
src/voronoi.c
with
17 additions
and
11 deletions
src/delaunay.c
+
14
−
9
View file @
de02a0d3
...
@@ -89,6 +89,19 @@ double det2(double a, double b, double c, double d) {
...
@@ -89,6 +89,19 @@ double det2(double a, double b, double c, double d) {
return
a
*
d
-
b
*
c
;
return
a
*
d
-
b
*
c
;
}
}
void
circleCenter
(
const
vertex
*
v1
,
const
vertex
*
v2
,
const
vertex
*
v3
,
vertex
*
center
)
{
double
ax
=
2
*
(
v1
->
x
-
v2
->
x
);
double
bx
=
2
*
(
v1
->
y
-
v2
->
y
);
double
cx
=
v1
->
x
*
v1
->
x
-
v2
->
x
*
v2
->
x
+
v1
->
y
*
v1
->
y
-
v2
->
y
*
v2
->
y
;
double
ay
=
2
*
(
v1
->
x
-
v3
->
x
);
double
by
=
2
*
(
v1
->
y
-
v3
->
y
);
double
cy
=
v1
->
x
*
v1
->
x
-
v3
->
x
*
v3
->
x
+
v1
->
y
*
v1
->
y
-
v3
->
y
*
v3
->
y
;
double
det
=
det2
(
ax
,
bx
,
ay
,
by
);
center
->
x
=
det2
(
cx
,
bx
,
cy
,
by
)
/
det
;
center
->
y
=
det2
(
ax
,
cx
,
ay
,
cy
)
/
det
;
}
/*
/*
* https://stackoverflow.com/questions/22791951/algorithm-to-find-an-arc-its-center-radius-and-angles-given-3-points
* https://stackoverflow.com/questions/22791951/algorithm-to-find-an-arc-its-center-radius-and-angles-given-3-points
* https://de.wikipedia.org/wiki/Cramersche_Regel
* https://de.wikipedia.org/wiki/Cramersche_Regel
...
@@ -97,15 +110,7 @@ double det2(double a, double b, double c, double d) {
...
@@ -97,15 +110,7 @@ double det2(double a, double b, double c, double d) {
//TODO seperate radius from this function
//TODO seperate radius from this function
circle
circleFrom3Points
(
vertex
v1
,
vertex
v2
,
vertex
v3
)
{
circle
circleFrom3Points
(
vertex
v1
,
vertex
v2
,
vertex
v3
)
{
circle
c
;
circle
c
;
double
ax
=
2
*
(
v1
.
x
-
v2
.
x
);
circleCenter
(
&
v1
,
&
v2
,
&
v3
,
&
c
.
center
);
double
bx
=
2
*
(
v1
.
y
-
v2
.
y
);
double
cx
=
v1
.
x
*
v1
.
x
-
v2
.
x
*
v2
.
x
+
v1
.
y
*
v1
.
y
-
v2
.
y
*
v2
.
y
;
double
ay
=
2
*
(
v1
.
x
-
v3
.
x
);
double
by
=
2
*
(
v1
.
y
-
v3
.
y
);
double
cy
=
v1
.
x
*
v1
.
x
-
v3
.
x
*
v3
.
x
+
v1
.
y
*
v1
.
y
-
v3
.
y
*
v3
.
y
;
double
det
=
det2
(
ax
,
bx
,
ay
,
by
);
c
.
center
.
x
=
det2
(
cx
,
bx
,
cy
,
by
)
/
det
;
c
.
center
.
y
=
det2
(
ax
,
cx
,
ay
,
cy
)
/
det
;
c
.
radius
=
sqrt
((
v1
.
x
-
c
.
center
.
x
)
*
(
v1
.
x
-
c
.
center
.
x
)
+
(
v1
.
y
-
c
.
center
.
y
)
*
(
v1
.
y
-
c
.
center
.
y
));
c
.
radius
=
sqrt
((
v1
.
x
-
c
.
center
.
x
)
*
(
v1
.
x
-
c
.
center
.
x
)
+
(
v1
.
y
-
c
.
center
.
y
)
*
(
v1
.
y
-
c
.
center
.
y
));
return
c
;
return
c
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.c
+
1
−
1
View file @
de02a0d3
...
@@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
...
@@ -13,7 +13,7 @@ int main(int argc, char *argv[]) {
//input: 1. function 0=cws_delaunay 2. # of points, 3. # of executions
//input: 1. function 0=cws_delaunay 2. # of points, 3. # of executions
//create_image();
//create_image();
//write_ppm ( "sine.ppm" );
//write_ppm ( "sine.ppm" );
int
numberOfPoints
=
2
000
;
int
numberOfPoints
=
10
000
;
int
function
=
0
;
int
function
=
0
;
int
executions
=
1
;
int
executions
=
1
;
if
(
argc
>
0
)
{
if
(
argc
>
0
)
{
...
...
This diff is collapsed.
Click to expand it.
src/voronoi.c
+
2
−
1
View file @
de02a0d3
...
@@ -83,7 +83,8 @@ void voronoiCws(vertex* S, int size) {
...
@@ -83,7 +83,8 @@ void voronoiCws(vertex* S, int size) {
int
isTriangle
;
int
isTriangle
;
clockwiseNextDelaunayEdge
(
&
i
,
&
j
,
&
k
,
S
,
&
size
,
&
isTriangle
);
clockwiseNextDelaunayEdge
(
&
i
,
&
j
,
&
k
,
S
,
&
size
,
&
isTriangle
);
if
(
isTriangle
==
2
)
{
if
(
isTriangle
==
2
)
{
currentV
=
vertexCircle2vertex
((
vertexCircle
){
S
[
i
],
S
[
j
],
S
[
k
]});
//currentV = vertexCircle2vertex((vertexCircle){S[i], S[j], S[k]});
circleCenter
(
S
[
i
],
S
[
j
],
S
[
k
],
currentV
);
if
(
first
)
{
if
(
first
)
{
first
=
0
;
first
=
0
;
firstV
=
currentV
;
firstV
=
currentV
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment