[changeset] behavior of sph2cart() doesn't match matlab (?)
Ben Abbott
bpabbott at mac.com
Sat Jan 17 12:20:55 CST 2009
On Jan 16, 2009, at 11:09 AM, Ben Abbott wrote:
>
> On Friday, January 16, 2009, at 10:35AM, "michael tesch" <tesch1 at gmail.com
> > wrote:
>>
>> On Fri, Jan 16, 2009 at 6:35 AM, Ben Abbott <bpabbott at mac.com> wrote:
>>>
>>> On Jan 15, 2009, at 8:57 PM, michael tesch wrote:
>>>
>>>> GNU Octave, version 3.0.2, on macosx, from 'port'.
>>>>
>>>> I can't actually verify this on the matlab side, but I got code
>>>> that
>>>> was developed in matlab that did the following:
>>>>
>>>> for nsp=1:sz
>>>> [TH,PHI]=cart2sph(xx,yy,zz);
>>>> [X,Y,Z]=sph2cart(TH,PHI,A);
>>>> spoke=[X ;Y ;Z];
>>>> end
>>>>
>>>> Where xx,yy,zz,TH,PHI were all scalars, and A was a 1xN vector.
>>>> The
>>>> result was that spoke was a matrix of 3xN.
>>>>
>>>> the Octave implementation of sph2cart() dies with an error about
>>>> mismatched dimensions of parameters.
>>>
>>>>
>>>
>>> I'm unable to reproduce any problem in the developers sources.
>>>
>>> Nothing depends upon "nsp", so why the loop?
>>>
>>> TH, PHI should each have same size as xx, yy, & zz. Are you sure A
>>> has the
>>> same size?
>>>
>>> To make certain everything is sized/shaped correctly, try
>>> inserting the line
>>> below after cart2sph
>>>
>>> whos xx yy zz TH PHI
>>>
>>> Ben
>>>
>>
>> thanks for your answer.
>>
>> sorry, i should have removed the loop from the example snippet.
>> the point is that the code works in matlab, but doesn't work in
>> octave,
>> because matlab's sph2cart() (apparently) accepts when TH and PHI
>> are scalars and A is a vector, whereas octave's sph2cart() bombs out.
>>
>> xx,yy,zz,TH,PHI are all scalars. A is a vector (of points along a
>> line)
>> and spoke should be the cartesian coordinates of the points along
>> that line.
>>
>> i have a workaround, but read that differences between octave and
>> matlab were considered bugs.
>>
>> mt
>>
>
> Ok, I understand and have confirmed the problem. Also, Matlab's
> documentation confirms their behavior is intended.
>
> I don't have time to look at the details at the moment. There are
> related functions that will need to be modified as well. I'll try to
> get to this tonight or over the weekend.
>
> Ben
Changeset attached. While permitting coordinates to be scalars, I
also took the liberty to change the variables to be all lower case.
In addition, the doc-strings have been changed and tests have been
added.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: changeset-cart2sph.patch
Type: application/octet-stream
Size: 10878 bytes
Desc: not available
Url : https://www-old.cae.wisc.edu/pipermail/bug-octave/attachments/20090117/9645736c/attachment.obj
-------------- next part --------------
More information about the Bug-octave
mailing list