Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
jdtuck committed Aug 21, 2023
1 parent 07ed002 commit bac4558
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions R/curve_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
calculatecentroid <- function(beta,returnlength = F){
n = nrow(beta)
T1 = ncol(beta)

betadot = apply(beta,1,gradient,1.0/(T1-1))
betadot = t(betadot)

normbetadot = apply(betadot,2,pvecnorm,2)
integrand = matrix(0, n, T1)
for (i in 1:T1){
integrand[,i] = beta[,i] * normbetadot[i]
}

scale = trapz(seq(0,1,length.out=T1), normbetadot)
centroid = apply(integrand,1,trapz,x = seq(0,1,length.out=T1))/scale
if(returnlength) return(list("length" = scale,"centroid" = centroid))
Expand Down Expand Up @@ -169,7 +169,11 @@ find_rotation_seed_coord <- function(beta1, beta2, mode="O"){

for (ctr in 0:end_idx){
if (mode=="C"){
beta2n = shift_f(beta2, scl*ctr)
if ((scl*ctr) <= end_idx){
beta2n = shift_f(beta2, scl*ctr)
} else {
break
}
} else {
beta2n = beta2
}
Expand Down

0 comments on commit bac4558

Please sign in to comment.