PerpendicVector
v2ベクトルのv1ベクトルに直交な成分の単位ベクトルとその長さを取り出す
PerpendicVector(v1,v2)
PerpendicVector<-function(v1,v2){
r1<-sqrt(sum(v1^2))
r2<-sqrt(sum(v2^2))
ret<-rep(0,length(v2))
ct<-0
if(r1*r2!=0){
ip<-sum(v1*v2)
ct<-ip/(r1*r2)
ret<-v2/r2-v1/r1*ct
ret<-ret/sqrt(sum(ret^2))
}
list(vector=ret,cos=ct)
}
\name{PerpendicVector}
\alias{PerpendicVector}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{
PerpendicVector
}
\description{
v2ベクトルのv1ベクトルに直交な成分の単位ベクトルとその長さを取り出す
}
\usage{
PerpendicVector(v1,v2)
}
%- maybe also 'usage' for other objects documented here.
\details{
%% ~~ If necessary, more details than the description above ~~
}
\value{
\item{vector}{unit vector}
\item{cos}{length}
}
\references{
%% ~put references to the literature/web site here ~
}
\author{
%% ~~who you are~~
}
\note{
%% ~~further notes~~
}
%% ~Make other sections like Warning with \section{Warning }{....} ~
\seealso{
}
\examples{
n<-5
v1<-runif(n)
v2<-runif(n)
PerpendicVector(v1,v2)
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ ~kwd1 }
\keyword{ ~kwd2 }% __ONLY ONE__ keyword per line