Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F10545928
LinearFunction.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
2 KB
Referenced Files
None
Subscribers
None
LinearFunction.cpp
View Options
#include
"LinearFunction.h"
LinearFunction
::
LinearFunction
()
{
//printf(" > Linear Function created\n");
LinearFunction
(
"no_name"
);
}
LinearFunction
::
LinearFunction
(
const
std
::
string
&
name
)
{
this
->
name
=
name
;
}
//bounded both-sided
Domain
*
LinearFunction
::
setDomain
(
bool
flagLowerBoundaryExist
,
float
lowerBoundary
,
bool
flagUpperBoundaryExist
,
float
upperBoundary
)
{
if
(
flagLowerBoundaryExist
&&
flagUpperBoundaryExist
&&
upperBoundary
>=
lowerBoundary
)
{
domain
.
setBoundaries
(
lowerBoundary
,
upperBoundary
);
//printf("%f - %f\n", domain.getLowerBoundary(), domain.getUpperBoundary());
return
&
domain
;
}
return
NULL
;
}
//bounded below
Domain
*
LinearFunction
::
setDomain
(
bool
flagLowerBoundaryExist
,
float
lowerBoundary
,
bool
flagUpperBoundaryExist
)
{
if
(
flagLowerBoundaryExist
&&
!
flagUpperBoundaryExist
)
{
domain
.
setLowerBoundary
(
lowerBoundary
);
//printf("%f - oo\n", domain.getLowerBoundary());
return
&
domain
;
}
return
NULL
;
}
//bounded above
Domain
*
LinearFunction
::
setDomain
(
bool
flagLowerBoundaryExist
,
bool
flagUpperBoundaryExist
,
float
upperBoundary
)
{
if
(
!
flagLowerBoundaryExist
&&
flagUpperBoundaryExist
)
{
domain
.
setUpperBoundary
(
upperBoundary
);
//printf("oo - %f\n", domain.getUpperBoundary());
return
&
domain
;
}
return
NULL
;
}
Domain
*
LinearFunction
::
setDomain
(
bool
flagLowerBoundaryExist
,
bool
flagUpperBoundaryExist
)
{
if
(
!
flagLowerBoundaryExist
&&
!
flagUpperBoundaryExist
)
{
domain
.
unsetBoundaries
();
return
&
domain
;
}
return
NULL
;
}
Domain
*
LinearFunction
::
getDomain
()
{
return
&
domain
;
}
std
::
string
LinearFunction
::
getName
()
{
return
this
->
name
;
}
bool
LinearFunction
::
setKandD
(
float
k
,
float
d
)
{
this
->
k
=
k
;
this
->
d
=
d
;
return
true
;
}
bool
LinearFunction
::
setKandD
(
float
x1
,
float
y1
,
float
x2
,
float
y2
)
{
if
(
x1
<
x2
)
{
k
=
(
y2
-
y1
)
/
(
x2
-
x1
);
}
else
if
(
x2
<
x1
)
{
k
=
(
y1
-
y2
)
/
(
x1
-
x2
);
}
else
{
k
=
1
;
d
=
0
;
return
false
;
}
d
=
y1
-
k
*
x1
;
return
true
;
}
float
LinearFunction
::
getK
()
{
return
k
;
}
float
LinearFunction
::
getD
()
{
return
d
;
}
float
LinearFunction
::
getY
(
float
x
)
{
float
y
;
y
=
k
*
x
+
d
;
return
y
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sat, May 30, 11:35 PM (12 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
329835
Default Alt Text
LinearFunction.cpp (2 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment