Calculating Vulcan and Cent using R

function( ce=cent.data.6.22.16.lat.dec, m=cnms.12.3 ){
ce = data.matrix( ce )

Vulcan

longitude

vulc.l = t( apply( ce[ , c(44,47,50,53) ], 1 , sort ) )
dvulc.l = cbind( vulc.l[ , 2:4 ] – vulc.l[ , 1:3 ], 360+vulc.l[ , 1 ]-vulc.l[ , 4 ] )
mult = t( apply( dvulc.l, 1, order ) )[ , 4 ]
vulc.ll = ( ( apply( vulc.l, 1, sum )+ mult*360 )*0.25 )%%360

declination

vulc.d = apply( ce[ , c( 45, 48, 51, 54 ) ], 1, sum )*pi/720

vulc.d = ( 180/pi )*asin( sin( vulc.d )*cos( ce[ , 1 ]*pi/180 ) +
cos( vulc.d )*sin( ce[ , 1 ]*pi/180 )*sin( vulc.ll*pi/180 ) )

Cent

longitude

cent.l = t( apply( ce[ , c( 38, 41 ) ], 1, sort ) )
dcent.l = cbind( cent.l[ , 2 ]-cent.l[ , 1 ], 360+cent.l[ , 1 ]-cent.l[ , 2 ] )
mult = t( apply( dcent.l, 1, order ) )[ , 2 ]
cent.ll = ( ( apply( cent.l, 1, sum ) + mult*360 )*0.5 )%%360

declination

cent.d = apply( ce[ , c( 39, 42 ) ], 1, sum )*pi/360

cent.d = ( 180/pi )*asin( sin( cent.d )*cos( ce[ , 1 ]*pi/180 ) +
cos( cent.d )*sin( ce[ , 1 ]*pi/180 )*sin( cent.ll*pi/180 ) )

put in matrix

ce = cbind( ce[ , c( 1, c(2,4)+rep( seq( 0, 12, 3 ), each=2 ) ) ],
vulc.ll, vulc.d, ce[ , c( 17, 19, 20, 22, 38, 40 ) ],
ce[ , c( c( 23, 25 ) + rep( seq( 0, 12, 3 ), each=2 ),
c( 44, 46 )+rep( seq( 0, 11, 3 ), each=2 ) ) ], ce[ , c( 41, 43 ) ], cent.ll, cent.d )
colnames( ce ) = paste( m, c( “”, rep( c( “.L”, “.D” ), 20 ) ), sep=”” )

ce
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s