Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grafika elso hf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Börcsök Barnabás
grafika elso hf
Commits
03d493f7
Commit
03d493f7
authored
Apr 4, 2020
by
bobarna
Browse files
Options
Downloads
Patches
Plain Diff
not working circle calculation
parent
a6617fc4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sirius.cpp
+16
-16
16 additions, 16 deletions
sirius.cpp
with
16 additions
and
16 deletions
sirius.cpp
+
16
−
16
View file @
03d493f7
...
@@ -185,17 +185,15 @@ public:
...
@@ -185,17 +185,15 @@ public:
float
r
;
//radius of the circle
float
r
;
//radius of the circle
Circle
(
vec2
p1
,
vec2
p2
,
vec2
p3
)
{
Circle
(
vec2
p1
,
vec2
p2
,
vec2
p3
)
{
float
m1
=
(
p2
.
y
-
p1
.
y
)
/
(
p2
.
x
-
p1
.
x
);
vec2
n12
=
p2
-
p1
;
//normal vector for perpendicular bisector of p1 and p2
float
m
2
=
(
p3
.
y
-
p2
.
y
)
/
(
p3
.
x
-
p2
.
x
);
float
f1
2
=
dot
(
n12
,(
p2
+
p1
)
/
2
);
float
mf1
=
-
1
/
m1
;
vec2
n23
=
p3
-
p2
;
//normal vector for perpendicular bisector of p1 and p2
float
m
f2
=
-
1
/
m2
;
float
f2
3
=
dot
(
n23
,
(
p2
+
p3
)
/
2
)
;
float
cf1
=
(
p2
.
x
*
p2
.
x
+
p2
.
y
*
p2
.
y
-
p1
.
x
*
p1
.
x
-
p1
.
y
*
p1
.
y
)
/
(
2
*
(
p2
.
y
-
p1
.
y
));
//coordinates for the circle's center
float
cf2
=
(
p3
.
x
*
p3
.
x
+
p3
.
y
*
p3
.
y
-
p2
.
x
*
p2
.
x
-
p2
.
y
*
p2
.
y
)
/
(
2
*
(
p3
.
y
-
p2
.
y
));
float
cx
=
(
f12
*
n23
.
y
-
f23
*
n12
.
y
)
/
(
n12
.
x
*
n23
.
y
-
n12
.
y
*
n23
.
x
);
float
cy
=
(
f12
/
n12
.
y
)
-
(
n12
.
x
/
n12
.
y
)
*
(
f12
*
n23
.
y
-
n12
.
y
*
f23
)
/
(
n12
.
x
*
n23
.
y
-
n12
.
y
*
n23
.
x
);
float
cx
=
(
cf2
-
cf1
)
/
(
mf1
-
mf2
);
float
cy
=
(
mf1
*
cf2
-
mf2
*
cf1
)
/
(
mf1
-
mf2
);
printf
(
"%f %f
\n
"
,
cx
,
cy
);
printf
(
"%f %f
\n
"
,
cx
,
cy
);
c
=
vec2
(
cx
,
cy
);
c
=
vec2
(
cx
,
cy
);
...
@@ -227,7 +225,7 @@ public:
...
@@ -227,7 +225,7 @@ public:
printf
(
"%d
\n
"
,
n
);
printf
(
"%d
\n
"
,
n
);
if
(
n
==
2
)
generateLineSegment
(
points
[
0
],
points
[
1
]);
if
(
n
==
2
)
generateLineSegment
(
points
[
0
],
points
[
1
]);
if
(
n
==
3
)
generateLineSegment
(
points
[
1
],
points
[
2
]);
if
(
n
==
3
)
generateLineSegment
(
points
[
1
],
points
[
2
]);
//
if(n == 3)
circles.emplace_back(Circle(p,
points[
1].p
, points[
1].inversion())
);
if
(
n
==
3
)
generateLineSegment
(
points
[
2
]
,
points
[
0
]
);
}
}
void
generateLineSegment
(
Point
p1
,
Point
p2
)
{
void
generateLineSegment
(
Point
p1
,
Point
p2
)
{
...
@@ -297,7 +295,7 @@ public:
...
@@ -297,7 +295,7 @@ public:
triangles
[
currTriangle
].
addPoint
(
p
);
triangles
[
currTriangle
].
addPoint
(
p
);
currPoints
++
;
currPoints
++
;
if
(
currPoints
==
3
)
currTriangle
++
,
triangles
.
emplace_back
(
SiriusTriangle
()),
currPoints
=
0
;
if
(
currPoints
==
3
)
currTriangle
++
,
currPoints
=
0
;
}
}
void
draw
()
{
void
draw
()
{
...
@@ -307,7 +305,6 @@ public:
...
@@ -307,7 +305,6 @@ public:
};
};
BaseCircle
baseCircle
=
BaseCircle
::
generate
();
BaseCircle
baseCircle
=
BaseCircle
::
generate
();
SiriusTriangleManager
siriusTriangleManager
=
SiriusTriangleManager
();
SiriusTriangleManager
siriusTriangleManager
=
SiriusTriangleManager
();
// Initialization, create an OpenGL context
// Initialization, create an OpenGL context
...
@@ -315,6 +312,9 @@ void onInitialization() {
...
@@ -315,6 +312,9 @@ void onInitialization() {
glViewport
(
0
,
0
,
windowWidth
,
windowHeight
);
glViewport
(
0
,
0
,
windowWidth
,
windowHeight
);
baseCircle
.
init
();
baseCircle
.
init
();
siriusTriangleManager
.
addPoint
(
vec2
(
-
0.6
,
0.4
));
siriusTriangleManager
.
addPoint
(
vec2
(
-
0.8
,
0.2
));
siriusTriangleManager
.
addPoint
(
vec2
(
-
0.2
,
-
0.6
));
// create program for the GPU
// create program for the GPU
gpuProgram
.
create
(
vertexSource
,
fragmentSource
,
"outColor"
);
gpuProgram
.
create
(
vertexSource
,
fragmentSource
,
"outColor"
);
...
@@ -382,10 +382,10 @@ void onMouse(int button, int state, int pX,
...
@@ -382,10 +382,10 @@ void onMouse(int button, int state, int pX,
break
;
break
;
}
}
siriusTriangleManager
.
addPoint
(
vec2
(
-
.8f
,
-
.4f
));
//
siriusTriangleManager.addPoint(vec2(-.8f, -.4f));
siriusTriangleManager
.
addPoint
(
vec2
(
-
.2f
,
-
.6f
));
//
siriusTriangleManager.addPoint(vec2(-.2f, -.6f));
siriusTriangleManager
.
addPoint
(
vec2
(
-
.4f
,
.4f
));
//
siriusTriangleManager.addPoint(vec2(-.4f, .4f));
siriusTriangleManager
.
draw
();
//
siriusTriangleManager.draw();
if
(
state
==
GLUT_DOWN
&&
button
==
GLUT_LEFT_BUTTON
)
{
if
(
state
==
GLUT_DOWN
&&
button
==
GLUT_LEFT_BUTTON
)
{
siriusTriangleManager
.
addPoint
(
vec2
(
cX
,
cY
));
siriusTriangleManager
.
addPoint
(
vec2
(
cX
,
cY
));
...
...
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