• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

127 Neutral

About kubapl

  • Rank
  1. Math Circle Help

    [quote name='EricTheRed' timestamp='1298054259' post='4776014'] It shouldn't be +=. just equal. Also, in your original code, why do you divide by Math.PI by 180? All of the trigonometric functions are in radians, are they not? You seem to be mixing radians and degrees though out your code. I have a feeling your angleStepSize is much to small to begin with. [/quote] I was under the impression that they were degrees. If I just initialize the angleStepSize to this double angleStepSize = Math.Acos( ( double ) ( texBrick.Width ) / ( double ) radius ); my number is 1.4580576603128359. Also if I just make the angle equal to the step size like this angle = 2 * Math.PI / Math.Floor( 2 * Math.PI / angleStepSize ); the app just hangs and then crashes with an error saying "An unhandled exeption of type "System.OutOfMemoryException" occurred in mscorlib.dll"
  2. Math Circle Help

    [quote name='EricTheRed' timestamp='1298049316' post='4775965'] [quote name='DigitalDisciple' timestamp='1298048608' post='4775960'] In order for the bricks to be divided evenly, it must be true that (2 * pi) % angleStepSize = 0. In other words, you must be able to divide 2 * pi by angleStepSize without any remainder. I believe that's what's going on with the outer circle...using the brick width in your equation will not guarantee that this condition is satisfied. I'm not sure what the best solution is at the moment, but there's the problem. [/quote] If you do this, re-assign angleStepSize to 2 * PI / floor(2 * PI / angleStepSize). Essential you are finding the most bricks you can fit (an integer) given their size, then dividing the arc evenly among them. [/quote] So I've tinkered with the numbers and did angle += ( 2 * Math.PI / Math.Floor( 2 * Math.PI / angleStepSize ) ); as you suggested but it appears as I lost all the width plus the distance in between the blocks by making this change If you look at the bottom left of the screen thats how big the block is its Width : 18 x Height 9 [attachment=1449:overlap.png]
  3. Math Circle Help

    I am trying to arrange bricks in a circular manner. I pretty much am taking the width of the brick image and dividing that by the hypo which is the radius of the circle and inverse cosining it. This give me the angle step that I need to use to figure out the x and y positions of the brick. I find that I still have some over lap in 1 spot. Heres a screenshot: [attachment=1447:overlap.png] I set the bricks alpha so you can better see the over lap Heres the code that I do the calculations: [code] private void DrawCircle( int radius ) { float x = 0.0f; float y = 0.0f; double angle = 0.0f; double angleStepSize = Math.Acos( (double)( texBrick.Width ) / (double)radius ) * ( Math.PI / 180 ); while( angle < 2 * Math.PI ) { x = ( float ) ( radius * Math.Cos( angle ) ); y = ( float ) ( radius * Math.Sin( angle ) ); spriteBatch.Draw( texBrick, new Vector2( x + graphics.GraphicsDevice.Viewport.Width / 2, y + graphics.GraphicsDevice.Viewport.Height / 2 ), new Rectangle( 0, 0, texBrick.Width, texBrick.Height ), new Color( 0.1f, 0.1f, 0.1f, 0.1f ), ( float ) ( (float)angle + 90.0f * ( Math.PI / 180.0f ) ), new Vector2( texBrick.Width * 0.5f, texBrick.Height * 0.5f ), 1.0f, SpriteEffects.None, 1.0f ); angle += angleStepSize * ( 3 * Math.PI ); } } [/code] The final line I do angle += angleStepSize * (3 * Math.PI ) I'm not sure why I added the 3 * Math.PI ... in my mind the angleStepSize should be enough.
  4. SharpSteer

    Hey, has anyone ported this AI library to the new XNA 4.0? [url="http://sharpsteer.codeplex.com/"]http://sharpsteer.codeplex.com/[/url] If not are there any good AI libs that someone can recommend? Thanks
  5. Dangling Pointers

    [quote name='nobodynews' timestamp='1295023641' post='4758895'] As said you should avoid that by avoiding the use of raw pointers in the first place. But no one's perfect. In which case there are memory leak detectors would help find such problems while you debug your program. [/quote] The detector I am using is the std one I'm guessing..? I came across it on the msdn site. [code] #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); [/code]
  6. Dangling Pointers

    Yes I do use smart pointers but I have an interview coming up and thought it would be a good idea to brush up on doing things manually.
  7. Dangling Pointers

    Hey guys, Quick question about pointers in c++. Recently I was reviewing pointers in C++ and I stumbled on this website <[url="http://www.codeguru.com/forum/showthread.php?t=312742"]http://www.codeguru.com/forum/showthread.php?t=312742[/url]> and the post has a example of a lost pointer: [code] class Sample { int* val; public: Sample() { val = new int; *val = 44; } ~Sample() { delete val; } }; void foo() { Sample* a = new Sample; Sample* b = new Sample; a = b; delete a; //actually deletes b //delete b; //already deleted } [/code] [size="2"]I'm just wondering whats the best way to deal with this situation and how would you go about deleting a?[/size] [size="2"]Thanks[/size]
  8. Calculus Help!

    [quote name='knighty' timestamp='1294605710' post='4756218'] Actually, you don't need[font="Arial"][size="2"] l'Hôpital's rule[/size][/font]. Just simplify the expressions in order to remove the denominator. [/quote] [font=verdana, arial, helvetica, sans-serif][size=2]Yeah we haven't covered L'Hopital's rule yet. I did attempt to simplify and cancel out both of these without any luck. My answers don't match with whats in the back of the textbook.[/size][/font]
  9. Calculus Help!

    Hello, I'm taking a university level calculus course this semester. I haven't done math since collage 3 years ago. Anyways we are currently solving limit problems and I'm able to figure out a bunch in my homework but I'm stuck on these. [img]http://uploads.gamedev.net/monthly_01_2011/post-139265-0-63493600-1294601764_thumb.png[/img] 1) lim 1/x - 1/2 / x-2 x->2 2) lim (4+h)^3 -64 / h h->0 I guess my big thing is I'm not sure what to do in situations when I have fractions or when dividing with just 1 variable. Any help would be great!
  10. GLSL Bytecode

    EngineCode: I've compiled the shader as per your instructions and I get this error: vertexshader.glsl (0) : error C5052: gl_Vertex is not accessable in this profile (0) : error C5052: gl_MultiTexCoord0 is not accessable in this profile (0) : error C5052: gl_Position is not accessable in this profile this is my GLSL code varying vec2 vTexCoord; void main(void) { vTexCoord = gl_MultiTexCoord0.xy; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
  11. GLSL Bytecode

    EngineCoder do you have an example.
  12. GLSL Bytecode

    Does CG toolkit have a GUI or is it just code that I add into my VS directory. Do you have a download?
  13. GLSL Bytecode

    Okay so maybe I wasn't to clear. I'm working on a project that does not support any high level shader languages. So what I am trying to do is write a GLSL shader and then have that translated to the equivalent ARB Assembly or Bytecode. Thanks
  14. GLSL Bytecode

    Right .. so what I want to do is write a GLSL shader and see the bytecode output.
  15. Hey guys, I'm looking to write some GLSL but need to output into bytecode is this possible? thanks
  • Advertisement