Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94181222
vect3d.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 4, 13:04
Size
1 KB
Mime Type
text/x-c
Expires
Fri, Dec 6, 13:04 (2 d)
Engine
blob
Format
Raw Data
Handle
22752663
Attached To
rSYMKIT symkit
vect3d.cpp
View Options
#include "vect3d.h"
#include <math.h>
Vector
&
operator
+=
(
Vector
&
v
,
const
Vector
&
w
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
v
[
i
]
+=
w
[
i
];
return
v
;
}
Vector
&
operator
-=
(
Vector
&
v
,
const
Vector
&
w
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
v
[
i
]
-=
w
[
i
];
return
v
;
}
Vector
&
operator
*=
(
Vector
&
v
,
double
k
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
v
[
i
]
*=
k
;
return
v
;
}
Vector
&
operator
/=
(
Vector
&
v
,
double
k
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
v
[
i
]
/=
k
;
return
v
;
}
Vector
operator
+
(
const
Vector
&
v
,
const
Vector
&
w
)
{
Vector
u
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
u
[
i
]
=
v
[
i
]
+
w
[
i
];
return
u
;
}
Vector
operator
-
(
const
Vector
&
v
,
const
Vector
&
w
)
{
Vector
u
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
u
[
i
]
=
v
[
i
]
-
w
[
i
];
return
u
;
}
Vector
operator
*
(
const
Vector
&
v
,
double
k
)
{
Vector
u
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
u
[
i
]
=
v
[
i
]
*
k
;
return
u
;
}
Vector
operator
/
(
const
Vector
&
v
,
double
k
)
{
Vector
u
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
u
[
i
]
=
v
[
i
]
/
k
;
return
u
;
}
/* cross product */
Vector
operator
^
(
const
Vector
&
v
,
const
Vector
&
w
)
{
Vector
u
;
u
[
0
]
=
v
[
1
]
*
w
[
2
]
-
v
[
2
]
*
w
[
1
];
u
[
1
]
=
v
[
2
]
*
w
[
0
]
-
v
[
0
]
*
w
[
2
];
u
[
2
]
=
v
[
0
]
*
w
[
1
]
-
v
[
1
]
*
w
[
0
];
return
u
;
}
/* dot product */
double
operator
*
(
const
Vector
&
v
,
const
Vector
&
w
)
{
double
x
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
x
+=
v
[
i
]
*
w
[
i
];
return
x
;
}
bool
operator
==
(
const
Vector
&
v
,
const
Vector
&
w
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
if
(
v
[
i
]
!=
w
[
i
])
return
false
;
}
return
true
;
}
bool
operator
!=
(
const
Vector
&
v
,
const
Vector
&
w
)
{
return
!
(
v
==
w
);
}
double
module
(
const
Vector
&
v
)
{
return
sqrt
(
sq_module
(
v
));
}
double
sq_module
(
const
Vector
&
v
)
{
double
x
=
0
;
for
(
int
i
=
0
;
i
<
3
;
++
i
)
x
+=
v
[
i
]
*
v
[
i
];
return
x
;
}
Vector
unit
(
const
Vector
&
v
)
{
return
v
/
module
(
v
);
}
Event Timeline
Log In to Comment