Add R
This commit is contained in:
parent
f37f200792
commit
19b2667210
5 changed files with 656 additions and 0 deletions
33
R/tools.R
Executable file
33
R/tools.R
Executable file
|
@ -0,0 +1,33 @@
|
|||
# Compute cartesian distance of two points
|
||||
computeCartDist=function(x1,y1,x2,y2){
|
||||
return(sqrt((x2-x1)^2+(y2-y1)^2));
|
||||
}
|
||||
|
||||
# Get line equation from two of his points y=ax+b
|
||||
getLineEquation=function(x1,y1,x2,y2){
|
||||
eq=NULL;
|
||||
if(x1!=x2){
|
||||
a=(y1-y2)/(x1-x2)
|
||||
b=y1-a*x1
|
||||
eq=c(a,b)
|
||||
}
|
||||
return(eq)
|
||||
}
|
||||
|
||||
# Get the middle point of a segment
|
||||
getMiddleOfSegment=function(x1,y1,x2,y2){
|
||||
x=(x1+x2)/2;
|
||||
y=(y1+y2)/2;
|
||||
return(c(x,y));
|
||||
}
|
||||
|
||||
# Convert dBm to Watt
|
||||
dBm2W=function(pdBm){
|
||||
return((10^(pdBm/10))/1000);
|
||||
}
|
||||
|
||||
# Convert Watt to dBm
|
||||
W2dBm=function(pW){
|
||||
return(10*log10(1000*pW));
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue