Re: [R] vector normal to a plane

About this list Date view Thread view Subject view Author view Attachment view

From: Thomas Lumley (tlumley@u.washington.edu)
Date: Sat 29 May 2004 - 07:55:48 EST


Message-id: <Pine.A41.4.58.0405281433000.25454@homer03.u.washington.edu>


W is looking for the vector cross product (a specifically
three-dimensional object important in physics and engineering). The
crossproduct() function provides a matrix product so that crossprod(x,y)
is t(x)%*%y, something completely different.

For the three-dimensional case you could define the cross and dot products

 "%x%"<-function(a,b) {c(a[2]*b[3]-a[3]*b[2], -a[1]*b[3]+a[3]*b[1],
a[1]*b[2]-a[2]*b[1])}

 "%.%%<-function(a,b) sum(a*b)

It would make sense, of course, to check that the arguments actually were
vectors of length 3.

        -thomas

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:13 EST