Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
emonyi
/
IAX0583
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c6e93e85
authored
Nov 05, 2018
by
emonyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
3e981cab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
0 deletions
lab5/task2.c
lab5/task2.c
0 → 100644
View file @
c6e93e85
#include <stdio.h>
#include <math.h>
int
main
(){
int
i
,
j
;
int
matrixArray1
[
1
][
3
]
=
{
{
1
,
4
,
6
}
};
int
matrixArray2
[
1
][
3
]
=
{
{
2
,
-
3
,
1
}
};
int
matrixArray3
[
1
][
3
]
=
{
{
3
,
5
,
0
}
};
int
matrixArray4
[
1
][
3
]
=
{
{
3
,
1
,
-
3
}
};
float
aDOTb
=
0
,
aDOTc
=
0
,
aDOTd
=
0
,
bDOTc
=
0
,
bDOTd
=
0
,
cDOTd
=
0
,
magA
=
0
,
magB
=
0
,
magC
=
0
,
magD
=
0
;
float
ang1
,
ang2
,
ang3
,
ang4
,
ang5
,
ang6
;
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
magA
=
(
magA
+
(
matrixArray1
[
i
][
j
]
*
matrixArray1
[
i
][
j
]));
}
magA
=
sqrt
(
magA
);
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
magB
=
(
magB
+
(
matrixArray2
[
i
][
j
]
*
matrixArray2
[
i
][
j
]));
}
magB
=
sqrt
(
magB
);
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
magC
=
(
magC
+
(
matrixArray3
[
i
][
j
]
*
matrixArray3
[
i
][
j
]));
}
magC
=
sqrt
(
magC
);
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
magD
=
(
magD
+
(
matrixArray4
[
i
][
j
]
*
matrixArray4
[
i
][
j
]));
}
magD
=
sqrt
(
magD
);
}
// last bit of magnitude
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
aDOTb
=
aDOTb
+
matrixArray1
[
i
][
j
]
*
matrixArray2
[
i
][
j
];
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
aDOTc
=
aDOTc
+
matrixArray1
[
i
][
j
]
*
matrixArray3
[
i
][
j
];
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
aDOTd
=
aDOTd
+
matrixArray1
[
i
][
j
]
*
matrixArray4
[
i
][
j
];
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
bDOTc
=
bDOTc
+
matrixArray2
[
i
][
j
]
*
matrixArray3
[
i
][
j
];
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
bDOTd
=
bDOTd
+
matrixArray2
[
i
][
j
]
*
matrixArray4
[
i
][
j
];
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
for
(
j
=
0
;
j
<
3
;
j
++
){
cDOTd
=
cDOTd
+
matrixArray3
[
i
][
j
]
*
matrixArray4
[
i
][
j
];
}
}
//finish with dot products
ang1
=
acos
(
aDOTb
/
(
magA
*
magB
));
ang2
=
acos
(
aDOTc
/
(
magA
*
magC
));
ang3
=
acos
(
aDOTd
/
(
magA
*
magD
));
ang4
=
acos
(
bDOTc
/
(
magB
*
magC
));
ang5
=
acos
(
bDOTd
/
(
magB
*
magD
));
ang6
=
acos
(
cDOTd
/
(
magC
*
magD
));
printf
(
"%f
\n
%f
\n
%f
\n
%f
\n
%f
\n
%f"
,
ang1
,
ang2
,
ang3
,
ang4
,
ang5
,
ang6
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment