Skip to content

Commit 44eea25

Browse files
committed
Fix issues + add read_mat()
1 parent 27571b6 commit 44eea25

File tree

5 files changed

+56
-7
lines changed

5 files changed

+56
-7
lines changed

Diff for: NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export(Remplir)
99
export(Rota_Inverse_YZ)
1010
export(Rota_YZ)
1111
export(XYZ_Vers_Agl)
12+
export(read_mat)

Diff for: R/CreaPoints.R

+2-7
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,10 @@ CreaPoints = function(MOE, CIS, matExp){
113113
DAppliPoidsFeuil = sin(XDistance / tail(XDistance,1) * pi) * dF
114114

115115
#===============================================================================
116-
# Resultat
117-
matrix(c(X,Y,Z,TypeSection,Base,Hauteur,
118-
PoidsTige,PoidsFeuillesDroite,PoidsFeuillesGauche,
119-
ModuleElasticite,ModuleCisaillement,AngleSection,
120-
DAppliPoidsFeuil), ncol = NpointsExp, byrow = TRUE)
121-
116+
# Resultats
122117
matrix(unlist(c(X,Y,Z,TypeSection,Base,Hauteur,
123118
PoidsTige,PoidsFeuillesDroite,PoidsFeuillesGauche,
124119
ModuleElasticite,ModuleCisaillement,AngleSection,
125120
DAppliPoidsFeuil)), ncol = NpointsExp, byrow = TRUE)
126-
121+
# x y z type b h mass leaves_mass_right leaves_mass_left elastic_modulus shear_modulus torsion distance
127122
}

Diff for: R/read_mat.R

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#' Read field matrix
2+
#'
3+
#' Read the matrix from field measurements.
4+
#'
5+
#' @param path Path to the file
6+
#'
7+
#' @return A formatted [data.frame()]
8+
#' @export
9+
#'
10+
#' @examples
11+
#' filepath = system.file("extdata/6_EW01.22_17_kanan.txt", package = "deformation")
12+
#' matExp = read_mat(filepath)
13+
read_mat = function(path){
14+
matExp = data.table::fread(path, data.table = FALSE)
15+
if(nrow(matExp) != 12){
16+
stop("File not in the right format, expected 12 columns, found ",
17+
nrow(matExp), ". Did you try to read a data.frame ? In that ",
18+
'case use e.g.:\n`data.table::fread("',path,'"',", data.table = FALSE)`")
19+
}
20+
df = data.frame(t(matExp))
21+
22+
colnames(df) = c("distance","type","width","heigth","inclination",
23+
"torsion","x","y","z","mass","mass_right",
24+
"mass_left")
25+
df
26+
}

Diff for: inst/extdata/6_EW01.22_17_kanan_df.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distance,type,width,heigth,inclination,torsion,x,y,z,mass,mass_right,mass_left
2+
0,1,0.0755,0.0411,48.8,4,0,0,0,0,0,0
3+
1.34,2,0.03291,0.0303,48.8,4,1.11,0.25,0.79,1.3036,0.1339,0.1654
4+
1.34,3,0.0181,0.02982,48.8,4,2.196,0.275,1.07,0.6466,0.4388,0.4828
5+
0.77,4,0.01144,0.01121,48.8,4,3.056,0.38,1.01,0.123,0.2568,0.2411
6+
0.77,5,0.001,0.001,48.8,4,3.791,0.53,0.42,0.0347,0.0962,0.102

Diff for: man/read_mat.Rd

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)