Jump to content

  • Log In with Google      Sign In   
  • Create Account

Ahmed Egyptian

Member Since 05 Mar 2013
Offline Last Active Nov 29 2013 10:33 AM

Topics I've Started

Setting an offset between centipede nodes

25 November 2013 - 04:06 PM

Hi All,

 

I'm trying to set an offset for a snake or centipede nodes. I don't know the math behind it.  The centipede nodes follow the head, hence the position is copied. 

 

I tried the following idea, but it didnt work

for (var i:int = m_nodes.length - 1; i >= 0; --i)
{
if (i != 0)
{
/* 
m_nodes[i].x = m_nodes[i - 1].x;
m_nodes[i].y = m_nodes[i - 1].y;*/
var currAngle:int = m_nodes[i].rotation + m_nodes[i-1].rotation;


trace("curr Angle"+currAngle);
m_nodes[i].x = m_nodes[i - 1].x + Math.cos(currAngle);
m_nodes[i].y = m_nodes[i - 1].y + Math.sin(currAngle);


}


else
{
m_nodes[0].x += m_nodes[0].vx * (100) * dt;
m_nodes[0].y += m_nodes[0].vy * (100) * dt;


}
}

Probability question

20 November 2013 - 04:33 PM

Consider that I have two columns 

1  6

2  9

5  10

 

If each elemtn from the first column I generate a random number from 1 - > 3  and for each element for the 2nd column I generate a number from 4 -->6 

 

What is the probability that I get again the same numbers that was generated before  and for how many times ?

 


Visualizing and writing algorithms

27 March 2013 - 06:22 AM

Hi All,

I have figured out a problem that I have. I've been developing software for number of years but most of the software I did was just Input/output. No algorithms are involved.

I know for example how binarysearch works, like it divides the array in two, then search left or right and that optimizes the searching.

When I try to write the code off my head, I can't. Even for insertion sorts, things like a[j+1] = a[j], in general playing with arrays or these things, I can't visualize or write them off my head. I don't know why, I didn't CS, but I'm EE :/.

How can I be better in writing algorithms :/ or at least understand the code in my head and visualize it


explaining arm neon code

21 March 2013 - 03:52 AM

Hi all,

 

so I'm trying to resize and downsample it by 3.

So I'm trying to get how the iterations occurred like srcHeight/3 and the math behing srcPitch*3, and s[0]. s[width], s[width*3]

  for (int r = 0; r < srcHeight/3; r++)
    {
        d = &dst[iDestPitch* r];
        s = &src[iSrcPitch * r*3];

        for (int c = 0; c < srcWidth/3; c+=8)
        {
            // ------------------
            //   B1  B4  B7 ... B B B
            //   B2  B5  B8 ... B B B
            //   B3  B6  B9 ... B B B
            // -------------------
            // load 8 sets of 3x3 pixels (grayscale)
            u88line0 = vld3_u8(&s[0]);
            u88line1 = vld3_u8(&s[iSrcPitch]);
            u88line2 = vld3_u8(&s[iSrcPitch*2]);
            s += 24;
   //processing

 


Explaning Image downsample

13 March 2013 - 03:33 PM

Hi All,

I tried to figure out the meaning of that function, I couldn't, even tried on paper, but didn't get it. Would someone explain that to me smile.png ? If that's possible with Ascii text or some images would be so much appreciated.

 

 

static void inline resizeRow(uint32_t *dst, uint32_t *src, uint32_t pixelsPerRow)

{
        uint8_t * pSrc8 = (uint8_t *)src;
        uint8_t * pDest8 = (uint8_t *)dst;
        int stride = pixelsPerRow * sizeof(uint32_t);
        int x;
        int r, g, b, a;


        for (x=0; x<pixelsPerRow; x++)
        {
                r = pSrc8[0] + pSrc8[4] + pSrc8[stride+0] + pSrc8[stride+4];
                g = pSrc8[1] + pSrc8[5] + pSrc8[stride+1] + pSrc8[stride+5];
                b = pSrc8[2] + pSrc8[6] + pSrc8[stride+2] + pSrc8[stride+6];
                a = pSrc8[3] + pSrc8[7] + pSrc8[stride+3] + pSrc8[stride+7];
                pDest8[0] = (uint8_t)((r + 2)/4); // average with rounding
                pDest8[1] = (uint8_t)((g + 2)/4);
                pDest8[2] = (uint8_t)((b + 2)/4);
                pDest8[3] = (uint8_t)((a + 2)/4);
                pSrc8 += 8; // skip forward 2 source pixels
                pDest8 += 4; // skip forward 1 destination pixel
        }
}
 

PARTNERS