Skip to content

Instantly share code, notes, and snippets.

@sinc
sinc / phase.py
Last active June 16, 2023 13:55
Parametrics phase methods
def phase1MNK(sig1, sig2, N, K = 0, Q = 1):
    num = 0.0
    denom = 0.0
    for n in range(K+4, N+K):
        x1n  = sig1[n - Q*0]
        x1n1 = sig1[n - Q*1]
        x1n3 = sig1[n - Q*3]
        x1n4 = sig1[n - Q*4]
        x2n  = sig2[n - Q*0]
        x2n1 = sig2[n - Q*1]
@sinc
sinc / gist:8691952
Created January 29, 2014 16:44
Exporting Maple plots
plot(sin,0..2*Pi);
plottools:-getdata(%);
M:=%[-1];
ExportMatrix("E:/MapleDiverse/MaplePrimes/test.dat",M);
@sinc
sinc / gist:2409107
Created April 17, 2012 21:16
get rotation matrix from accelerometer
CMRotationMatrix rotationMatrixFromGravity(float x, float y, float z)
{
// The Z axis of our rotated frame is opposite gravity
vec3f_t zAxis = vec3f_normalize(vec3f_init(-x, -y, -z));
// The Y axis of our rotated frame is an arbitrary vector perpendicular to gravity
// Note that this convention will have problems as zAxis.x approaches +/-1 since the magnitude of
// [0, zAxis.z, -zAxis.y] will approach 0
vec3f_t yAxis = vec3f_normalize(vec3f_init(0, zAxis.z, -zAxis.y));
@sinc
sinc / gist:2375480
Created April 13, 2012 09:50
клевый метод показать, что в таблице нет элементов.
m_pTable.tableFooterView = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 100.0f)];
((UILabel*)m_pTable.tableFooterView).text = @"Ничего не найдено";
((UILabel*)m_pTable.tableFooterView).textColor = [UIColor grayColor];
((UILabel*)m_pTable.tableFooterView).textAlignment = UITextAlignmentCenter;
   
UIEdgeInsets e = UIEdgeInsetsMake(0, 0, -100, 0);
[m_pTable setContentInset:e];
@sinc
sinc / gist:1925626
Created February 27, 2012 17:23
Gradient
ret_corners[num_corners].dIx = (p[pixel[4]] - p[pixel[12]]) +
(p[pixel[3]] + p[pixel[5]] - p[pixel[11]] - p[pixel[13]])*0.924f +
(p[pixel[2]] + p[pixel[6]] - p[pixel[10]] - p[pixel[14]])*0.707f +
((p[pixel[1]] + p[pixel[7]] - p[pixel[9]] - p[pixel[15]])*0.383f);
ret_corners[num_corners].dIy = (p[pixel[0]] - p[pixel[8]]) +
(p[pixel[1]] + p[pixel[15]] - p[pixel[7]] - p[pixel[9]])*0.924f +
(p[pixel[2]] + p[pixel[14]] - p[pixel[6]] - p[pixel[10]])*0.707f +
((p[pixel[3]] + p[pixel[13]] - p[pixel[5]] - p[pixel[11]])*0.383f);