Re: [R] vector normal to a plane

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

From: Uwe Ligges (ligges@statistik.uni-dortmund.de)
Date: Sat 29 May 2004 - 07:35:27 EST


Message-id: <40B7B09F.4010006@statistik.uni-dortmund.de>

Uwe Ligges wrote:

> wwsprague@ucdavis.edu wrote:
>
>> Hi All,
>>
>> (I have a degree in math, but I am too embarassed to ask my
>> colleagues, so here goes:)
>>
>> I would like to get a vector normal (orthogonal) to a plane formed by
>> two other vectors. In matlab I do this:
>>
>> v1 = [.4, .6, .8]; v2 = [.9, .7, .2]; nn = cross(v1,v2) (gives ~[-.48,
>> .65, -.24]
>
>
> Huh?
>
> I don't have access to Matlab. Can you tell me how cross() is defined in
> Matlab (it's not obvious to me - at least not at 10:40 pm - how can
> anything get negative)?

My apologies - and thanks to Rolf Turner who told me the truth (well, I
anticipated that it's getting too late this friday evening).

OK, I don't think what you are looking for is defined as a function in
R. Anyway, for the 3D case it's pretty easy to write the result in one
line of code ...

Uwe

>
>
>>
>> if I do R> cross(v1, v2), I get .94. Huh?
>
>
> Ha! ;-)
>
> crossprod(v1, v2):
> 0.4*0.9 + 0.6*0.7 + 0.8*0.2 = 0.94
>
> Uwe Ligges
>
>
>
>> Thanks for all your help, again.
>>
>> W
>>
>> ______________________________________________
>> 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
>
>
> ______________________________________________
> 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

______________________________________________
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