Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What is the effect?</p> <p>I just note that there are two bugs:</p> <ul> <li>calculating the distance</li> <li>the dimension of quad</li> </ul> <p>The distance code has some errors, try this:</p> <pre><code>int distx = (quadTopLeftCorner.x - lastTopLeftQuadPoint.x) * (quadTopLeftCorner.x -lastTopLeftQuadPoint.x); int disty = (quadTopLeftCorner.y- lastTopLeftQuadPoint.y) * (quadTopLeftCorner.y - lastTopLeftQuadPoint.y); int dist = sqrtf(distx + disty); </code></pre> <p>Also you need to multiple two time the someFloatValue if you compose the quad from top-left corner:</p> <pre><code>someNewPointForTopLeft.x = ((quadTopLeftCorner.x + lastTopLeftQuadPoint.x)/2); someNewPointForTopLeft.y = ((quadTopLeftCorner.y + lastTopLeftQuadPoint.y)/2); someNewPointForTopRight.x = someNewPointForTopLeft.x + someFloatValue*2; someNewPointForTopRight.y = someNewPointForTopLeft.y; someNewPointForBottomRight.x = someNewPointForTopLeft.x + someFloatValue*2; someNewPointForBottomRight.y = someNewPointForTopLeft.y - someFloatValue*2; someNewPointForBottomLeft.x = someNewPointForTopLeft.x; someNewPointForBottomLeft.y = someNewPointForTopLeft.y - someFloatValue*2; </code></pre> <p>Anyway, to improve code and future managements I suggest to change you code introducing a Vector library and make a code like this:</p> <pre><code>Vector a = lastPoint; Vector b = currentPoint; Vector newPointForQuad=lastPoint; if ( (lastPoint-currentPoint).dist()&gt; someDistanceValue) newPointForQuad = (lastPoint + currentPoint)/2; Quad quad = makeQuadAroundPoint(newPointForQuad, someQuadSize); </code></pre> <p>Hope this help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload