need help solving a logic problem.

About Monkey 2 Forums Monkey 2 Programming Help need help solving a logic problem.

This topic contains 8 replies, has 3 voices, and was last updated by  Jesse 2 years, 4 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #5278

    Jesse
    Participant

    I have a logic problem I can’t figure out. I an trying to create a shape editor program. but I ran into problems when trying to create an arc while using the mouse. the Arc end points are handles that can be moved to increase or decrease the size of it’s circumference. and thats exactly where the problem is. I can move the handles to a certain point after that it draws the arc in reverse. it has to do with the way ATan2 Works.

    I am posting and extract from my program in hope someone can help me figure this out. Use the mouse on the handles to edit the shape:

    [/crayon]

    I have tried several different ways of doing it but I can’t seem to figure out how to solve it.

    #5279

    codifies
    Participant

    it would be easier to test with this #Import “vec2d.monkey2”

    jplib?

    can you reduce it to a minimal example that can be run on the defaul modules ?

    #5280

    Jesse
    Participant

    sorry I forgot about that. Corrected source code!

    #5298

    codifies
    Participant

    nice…. thats a proper pain!

    I had a quick fiddle but no joy and speaking of joy http://gamedev.stackexchange.com/questions/46552/360-degree-rotation-skips-back-to-0-degrees-when-using-math-atan2y-x

    interested to see how you get on….

    #5312

    Jesse
    Participant

    I’m going to have to scrap that idea somewhat and use vector sequence instead. It’ll help me freshen up on my vector math.

    #5324

    abakobo
    Participant

    here is some working example with starting and ending point, so if you invert the handles to arc will flip.
    May be you don’t want it to flip when the angle is small. EDIT: If so just invert start and end when the switch occurs. Won’t work “just” like that…
    You should have used Vec2f instead of redefine a vec2. Monkey is full of little gentle things like that..

    [/crayon]
    #5325

    Jesse
    Participant

    Oh, this is good! Thanks abakobo. that did it. I haven’t gone trough the code to see how you did it but it works so Thank you.

    >You should have used Vec2f instead of redefine a vec2. Monkey is full of little gentle things like that..

    I had several reasons for using my own Vector class. the #1 reason I had for using it was that I have some functionality on it that the default module does not have and I will be needing it in the long run. Another is that since I am using pointers to determine where the if statements take action and a null is needed and since the default vector is a structure it is really never Null, You don’t even have to create an instance of the structure for it to have a value or access its fields, so It was no use for this program.

    #5326

    abakobo
    Participant

    Structs goes on the stack and classes on the heap… So structs are theoretically faster.. if you’ll use your vects in very iterative process it will slowdown your app. In some very hungry loops it’s even interresting to use x and y with no structs at all!

    #5327

    Jesse
    Participant

    I know how they work, but I wasn’t looking for speed. I just needed it to work. I know there are other ways I could have done it to make it even faster but it served it’s purpose so I am fine with it. Thanks for the advice anyway.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.