Next: histograms, Previous: general, Up: Directory Index [Contents][Index]
computes the rotation matrix for an *active* rotation by angle around the axis rotAxis (3d vector)
rotMatrix = rotationMatrix(1.357, [0.9, 8.7, 6.5]); sert(ismatrix(rotMatrix)) sert(rotMatrix' * rotMatrix, eye(3), 1e-3)
Convert a sky-position given in terms of longitude and latitude’
angles into a unit vector vn = [nx, ny, nz]
in the same reference frame
(ie either in equatorial or ecliptic system).
inputs {longitude, latitude} are allowed to be vectors, ie the input
LongLat must be of size N x 2.
returns unit-vector vn = [ nx, ny, nz ]
of column-vectors nx,ny,nz
Ntrials = 1000; LongLatIn = [ octforge_unifrnd(0, 2*pi, Ntrials, 1 ), octforge_unifrnd(-pi/2, pi/2, Ntrials, 1) ]; vn = skyAngles2Vector ( LongLatIn ); LongLatOut = skyVector2Angles ( vn ); maxerr = max ( abs ( LongLatIn(:) - LongLatOut(:) ) ); assert ( maxerr < 1e-6 );
Convert a sky-position given in terms of ’longitude’ and ’latitude’
angles into a unit vector vn = [nx, ny, nz]
in the same reference frame
(ie either in equatorial or ecliptic system).
convert input sky-position in ecliptic reference frame into equatorial frame
Input 3-vectors are interpreted as sky-vectors vn = [nx, ny, nz]
(un-normalized),
while 2-vectors are interpreted as sky angles [longitude, latitude],
and the output uses the same format as the input (ie vector –> vector, angles–>angles).
Multiple values can be input as column-vectors, ie Nx3 for vectors vn, Nx2 for angles
simple wrapper for skyRotateFrame()
Ntrials = 10; LongLatEclIn = [ octforge_unifrnd(0, 2*pi, Ntrials, 1 ), octforge_unifrnd(-pi/2, pi/2, Ntrials, 1 ) ]; vnEclIn = octforge_unifrnd(-1, 1, Ntrials, 3 ); LongLatEqu1 = skyEcliptic2Equatorial ( LongLatEclIn ); vnEqu1 = skyEcliptic2Equatorial ( vnEclIn ); LongLatEclOut = skyEquatorial2Ecliptic ( LongLatEqu1 ); vnEclOut = skyEquatorial2Ecliptic ( vnEqu1 ); err1 = max ( abs ( LongLatEclIn - LongLatEclOut )(:) ); err2 = max ( abs ( vnEclIn - vnEclOut )(:) ); assert ( (err1 < 1e-6) && (err2 < 1e-6 ) );
Convert a sky-position given in terms of ’longitude’ and ’latitude’
angles into a unit vector vn = [nx, ny, nz]
in the same reference frame
(ie either in equatorial or ecliptic system).
convert input sky-position in equatorial reference frame into ecliptic frame
Input 3-vectors are interpreted as sky-vectors vn = [nx, ny, nz]
(un-normalized),
while 2-vectors are interpreted as sky angles [longitude, latitude],
and the output uses the same format as the input (ie vector –> vector, angles–>angles).
Multiple values can be input as column-vectors, ie Nx3 for vectors vn, Nx2 for angles
simple wrapper for skyRotateFrame()
LongLatEqu = [ 1.5, -0.5; 2.6, 0.7 ]; LongLatEclCheck = [ 1.469781, -0.907669; 2.385547, 0.449178 ]; ## converted using frostydrew.org/utilities.dc/convert/tool-eq_coordinates/ LongLatEcl = skyEquatorial2Ecliptic ( LongLatEqu ); err = max ( abs ( LongLatEcl - LongLatEclCheck )(:) ); assert ( err < 1e-5 );
Convert a sky-position given in terms of ’longitude’ and ’latitude’
angles into a unit vector vn = [nx, ny, nz]
in the same reference frame
(ie either in equatorial or ecliptic system).
convert input sky-position by rotating the reference by angle around 3-vector axis’
Input 3-vectors are interpreted as sky-vectors vn = [nx, ny, nz]
(un-normalized),
while 2-vectors are interpreted as sky angles [longitude, latitude]
,
and the output uses the same format as the input (ie vector –> vector, angles–>angles).
Multiple values can be input as column-vectors, ie Nx3 for vectors vn, Nx2 for angles
assert(skyRotateFrame([0.1, 2.3, 4.5], 1.234, [9.8, 7.6, 5.4]), [3.0863, -1.0902, 3.8518], 1e-3)
Convert a sky-position given in terms of a 3-vector into ’longitude’ and ’latitude’ angles in the same reference frame (ie either in equatorial or ecliptic system).
input vSky must be a N x 3 vector (N>=1), returns matrix of the form [ longitude, latitude ] with column-vectors longitude in [0, 2pi] and latitude in [-pi, pi]
the input vector doesn’t need to be normalized
Ntrials = 1000; vnIn = randPointInNSphere ( 3, ones ( 1, Ntrials ) )'; LongLat = skyVector2Angles ( vnIn ); vnOut = skyAngles2Vector ( LongLat ); maxerr = max ( abs ( vnIn(:) - vnOut(:) ) ); assert ( maxerr < 1e-6 );
Returns the intersection of two lines defined by the locus of points pa = p1a + ua*(p2a - p1a) and pb = p1b + ub*(p2b - p1b) i.e. the values of ua and ub such that pa == pb.
[ua,ub] = TwoLineIntersection([-1;-1], [3;3], [-1;1], [1;-1]); assert(ua, 0.25, 1e-3); assert(ub, 0.5, 1e-3);
Next: histograms, Previous: general, Up: Directory Index [Contents][Index]