**From:** Gabor Grothendieck (*ggrothendieck@myway.com*)

**Date:** Sat 29 May 2004 - 09:31:32 EST

**Next message:**Torsten Steuernagel: "Re: [R] "privileged slots""**Previous message:**John Fox: "RE: [R] Converting data frame to array?"**In reply to:**Thomas Lumley: "Re: [R] vector normal to a plane"

Message-id: <loom.20040529T013001-346@post.gmane.org>

Thomas Lumley <tlumley <at> u.washington.edu> writes:

:

: 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])}

Alternately, you could get the cofactors from solve:

cross3 <- function(a,b) {

m <- cbind(a,b,1)

solve(m)[3,]*det(m)

}

______________________________________________

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

**Next message:**Torsten Steuernagel: "Re: [R] "privileged slots""**Previous message:**John Fox: "RE: [R] Converting data frame to array?"**In reply to:**Thomas Lumley: "Re: [R] vector normal to a plane"

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