Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Physical
Sep 26, 2007

by T. Finninho
Is there a hangout thread for CoC kind of like the TCC Weed Megathread or I guess the "poo poo that pisses you off" thread but more chill like "stuff you want to talk about and talk about with other programmers".

Adbot
ADBOT LOVES YOU

epswing
Nov 4, 2003

Soiled Meat

Physical posted:

Is there a hangout thread for CoC kind of like the TCC Weed Megathread or I guess the "poo poo that pisses you off" thread but more chill like "stuff you want to talk about and talk about with other programmers".

Don't think there's a hangout thread, but there's a hangout IRC channel. See the Cavern of Cobol FAQ.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Physical posted:

Is there a hangout thread for CoC kind of like the TCC Weed Megathread or I guess the "poo poo that pisses you off" thread but more chill like "stuff you want to talk about and talk about with other programmers".

the irc channel

mjau
Aug 8, 2008

Otto Skorzeny posted:

1) what sort of floating point exceptions do you think you are going to encounter here? Subnormals don't raise anything, they're just slow as a turd.

Sylink's probably talking about cumulative roundoff errors that will be dependent on the framerate (e.g. adding (float)1/2 twice isn't the same as adding (float)1/3 thrice), and since the framerate can be variable that means results can be variable too. In a physics simulation, that can be the difference between a ball bouncing left, bouncing right, blowing up everything, etc. It's a common problem in games that's solved by using a constant framerate for logic. (A fixed rate isn't enough for consistent floating point math, but it's one necessary piece.)

Anyway, here's a simple example of one way you could do that (C):
code:
then = get_current_time_in_ms();
while (alive) {
    now = get_current_time_in_ms();
    trigger += (now - then) * logic_hz;
    then = now;

    while (trigger >= 1000)
    {
        trigger -= 1000;
        tick();  // this is called logic_hz times per second
    }

    draw_etc();
}

Physical
Sep 26, 2007

by T. Finninho

epalm posted:

Don't think there's a hangout thread, but there's a hangout IRC channel. See the Cavern of Cobol FAQ.

Otto Skorzeny posted:

the irc channel
Yea I saw that but wanted a thread instead. Thanks anyway!

shrughes
Oct 11, 2008

(call/cc call/cc)

Sylink posted:

How do I add a tick rate into a program? I know game libraries often include these to limit the framerate and that is essentially what I need for command line output or something similar. This is because I imagine trying to calculate the time billions of times a second will add in all kinds of crazy errors.

Getting the time in seconds takes about 60 ns the second time you try. Using the rdtsc instruction to get the time in "cycles" will take about 20 ns. I forget how long time(NULL) takes, but it does not make a system call and it is something between 60 ns and 600 ns. There's also something that takes 130 ns. I think clock_gettime(CLOCK_MONOTONIC, ...) takes 60 ns, but I can't exactly remember.

shrughes fucked around with this message at 21:12 on Oct 30, 2012

Boz0r
Sep 7, 2006
The Rocketship in action.
I need an idea for an algorithm. I've got a list of 2D points where each point points to the one on the right. These make up one polygon for each loop. If there's a hole in the polygon right now, the polygon just covers the hole. I need an algorithm to tesselate these polygons so the holes are actually holes instead of just another polygon. My structures looks like this:

code:
Polygon 
{
    Points[]
    Point firstPoint
}

Point 
{
    x, y
    rightPoint
}
The points are arranged counter-clockwise, so if they're clockwise, it's a hole. I just don't really know how to find out if they're clockwise or not.

Any ideas?

shrughes
Oct 11, 2008

(call/cc call/cc)
I'd be willing to answer your question but first I'd like you to reply with the definition of "tesselate".

Boz0r
Sep 7, 2006
The Rocketship in action.
Oh, sorry. I'd like to cut the polygons up in triangles.

EDIT: like this one


I've found a couple of algorithms, but they either don't work with loops, or I don't know how to use them with my data structure.

Boz0r fucked around with this message at 21:31 on Oct 30, 2012

Jewel
May 2, 2009

Boz0r posted:

Oh, sorry. I'd like to cut the polygons up in triangles.

EDIT: like this one


Then don't define it like that? Can't you just define it as

3->7->6->0
0->6->5->1
1->5->4->2
2->4->7->3

:confused:

Boz0r
Sep 7, 2006
The Rocketship in action.
Yeah, for that specific one, but I have to deal with arbitrary polygons.

shrughes
Oct 11, 2008

(call/cc call/cc)

Boz0r posted:

Oh, sorry. I'd like to cut the polygons up in triangles.

My bad, I had a brain fart and completely forgot that usage.

Jewel
May 2, 2009

Boz0r posted:

Yeah, for that specific one, but I have to deal with arbitrary polygons.

I'unno, I'm sure there's probably a good use for this and I'm interested if there's an actual way to solve it, but why is whatever the data you're getting, allowed to be like that? Whatever's exporting the data probably should split it into 4 polys whenever whatever operation was done to it to make that scenario, otherwise imo the first image you provided is just two polygons over the top of each other. Just because someone wants data to mean something doesn't mean they can do a bad job at exporting/writing that data in the first place :colbert:

Mostly basing this off the fact I have no idea what this is for though, but SOMETHING had to create that data, and I assume if it's something like a 3D modelling program it should have split it into 4 polys to begin with.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


This looks very similar to a Delaunay triangulation. Is it? If not, will the algorithm work for this problem anyway?

Boz0r
Sep 7, 2006
The Rocketship in action.
I'm trying to extract map information from BUILD Engine maps and convert them to 3D models :D That's how it's represented in their files.

EDIT: That one actually looks like something I can use. I'll try giving it a shot.

Boz0r fucked around with this message at 21:49 on Oct 30, 2012

JawnV6
Jul 4, 2004

So hot ...

shrughes posted:

Using the rdtsc instruction to get the time in "cycles" will take about 20 ns.
Depending on your processor you also get to learn all about C states and P states and after tearing your hair out for a while finally understand why you should probably just chuck it to the OS for the minuscule hit.

omeg
Sep 3, 2012

And of course different cores can have different clock counts. And the clock frequency itself is variable more often than not.

necrobobsledder
Mar 21, 2005
Lay down your soul to the gods rock 'n roll
Nap Ghost
There's got to be some middle ground between using something like rdtsc and hoping your rtc syscall call uses a hardware RTC in some manner. Last I remember when I looked at sub-microsecond benchmarking seriously (literally 10 years ago), the only way to get a fairly accurate picture of function calls was to use both highly instrumented userland software like from Rational software and to utilize a kernel that uses event-based clocking for its multi-process management like HP/UX. The inaccuracy of timers was pretty much inversely proportional to the length of the function run indicating probably overhead of timing being at the minimum constant and possibly even higher as the measurement interval gets shorter.

tef
May 30, 2004

-> some l-system crap ->

Physical posted:

Is there a hangout thread for CoC kind of like the TCC Weed Megathread or I guess the "poo poo that pisses you off" thread but more chill like "stuff you want to talk about and talk about with other programmers".

There used be a thread like this, but it got taken away. The coccest pics you got, was a thread where we posted terrible pictures of things, and whined about stuff. It closed when YOSPOS opened.

YOSPOS (that forum next door), occasionally chats about programming, when it isn't talking about phones, cars or holding séances for the late steve jobs. http://forums.somethingawful.com/showthread.php?threadid=3481275 like this

:yayclod:

tef
May 30, 2004

-> some l-system crap ->
I also unfucked sn.printf.net

shrughes
Oct 11, 2008

(call/cc call/cc)

JawnV6 posted:

Depending on your processor you also get to learn all about C states and P states and after tearing your hair out for a while finally understand why you should probably just chuck it to the OS for the minuscule hit.

It's not a miniscule hit and rdtsc has had no practical problems for measuring timings for us and could you please provide instructions for how to write a version of asking for the time that involves a syscall?

friendbot2000
May 1, 2011

Okay, got another question for you all. So I am learning about partial classes and partial methods. However I am not really understanding the purpose of it all. I understand how to write the code and what it does but I am wondering what the purpose of doing partial classes and methods is. Why don't you just write a whole method or class down in one file versus splitting them between two files? Wouldn't that make more sense?

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
There are specific cases where partial classes and methods are useful, and they're not particularly useful in more general programming.

One example where they are useful is for interacting with automatically generated code - having autogenerated code live in its own file, entirely separate from code written by you, is really handy. The Visual Studio designer does this, for example - when you ask it to create a form, it makes a *.cs file for you to write your code, and a *.designer.cs file which is where it puts the code it generates for that form. That way it can easily modify the *.designer.cs file when you make changes to the form, without worrying about messing up the code you've written.

Physical
Sep 26, 2007

by T. Finninho

tef posted:

There used be a thread like this, but it got taken away. The coccest pics you got, was a thread where we posted terrible pictures of things, and whined about stuff. It closed when YOSPOS opened.

YOSPOS (that forum next door), occasionally chats about programming, when it isn't talking about phones, cars or holding séances for the late steve jobs. http://forums.somethingawful.com/showthread.php?threadid=3481275 like this

:yayclod:
Ah, why did it get taken away?

Also, I need to learn how to document code. Is Javadoc the standard and where is the best place to learn? Wikipedia is being pretty concise so far.

baquerd
Jul 2, 2007

by FactsAreUseless

Physical posted:

Ah, why did it get taken away?

Also, I need to learn how to document code. Is Javadoc the standard and where is the best place to learn? Wikipedia is being pretty concise so far.

In Java, it's certainly the standard. Not only will you have IDE integration in many cases, but there are built in tools to automatically convert your javadoc comments into a website just like the official docs.

ToxicFrog
Apr 26, 2008


Physical posted:

Ah, why did it get taken away?

Also, I need to learn how to document code. Is Javadoc the standard and where is the best place to learn? Wikipedia is being pretty concise so far.

Depends on what code. Different projects and communities will have different conventions for code documentation. Different languages will have different tools and support for it, in some cases built directly into the language.

In Java, I believe Javadoc is still the standard documenting tool.

JawnV6
Jul 4, 2004

So hot ...

shrughes posted:

It's not a miniscule hit and rdtsc has had no practical problems for measuring timings for us
Bolded the important bit, feel free take another whack at it:

JawnV6 posted:

Depending on your processor you also get to learn all about C states and P states and after tearing your hair out for a while finally understand why you should probably just chuck it to the OS for the minuscule hit.

shrughes
Oct 11, 2008

(call/cc call/cc)

JawnV6 posted:

Bolded the important bit, feel free take another whack at it:

If you have a really old processor? Who cares?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

shrughes posted:

If you have a really old processor? Who cares?

Those problems would occur with relatively new processors in certain conditions rather than old ones

Boz0r
Sep 7, 2006
The Rocketship in action.
When I have an array of 2D points(a loop), how can I know if they're clockwise or not, and if another point is inside or outside of the loop?

shrughes
Oct 11, 2008

(call/cc call/cc)

Otto Skorzeny posted:

Those problems would occur with relatively new processors in certain conditions rather than old ones

Your response seems awfully vague.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

Boz0r posted:

When I have an array of 2D points(a loop), how can I know if they're clockwise or not, and if another point is inside or outside of the loop?

Do you already know whether they form a convex shape, or can you make no assumptions?

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

shrughes posted:

Your response seems awfully vague.

It is, because I don't have the time or the inclination to make an effortpost on ACPI

shrughes
Oct 11, 2008

(call/cc call/cc)

Otto Skorzeny posted:

It is, because I don't have the time or the inclination to make an effortpost on ACPI

Then please answer this simple question. When does ACPI affect values returned by rdtsc in modern processors?

Boz0r
Sep 7, 2006
The Rocketship in action.

Internet Janitor posted:

Do you already know whether they form a convex shape, or can you make no assumptions?

No assumptions, sadly. It's just a bunch of 2D points with a pointer to the one on the right.

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

shrughes posted:

Then please answer this simple question. When does ACPI affect values returned by rdtsc in modern processors?

This depends on whether you are interpreting the TSC as a "cycle counter" or a timer. In the latter case, anything recent will indeed be fine (and you can check whether you're recent enough quite easily); in the former case, you can still be hosed! Of course there are other gochas that I assume you're controlling for wrt core affinity etc - Agner Fogg's instruction latency work gives a good example of what you should account or at least control for.

movax
Aug 30, 2008

shrughes posted:

Then please answer this simple question. When does ACPI affect values returned by rdtsc in modern processors?

Triggering a SMI to enter SMM can completely and utterly trash timing-dependent / real-time code. You could literally leave OS execution and hit up an EFI runtime service exposed in the EFI System Table (or a call to some legacy BIOS code as well).

On most platforms, hitting IO Port 0xB2 will have the effect of triggering some SMI handler, be it unlocking/locking flash, munging CMOS, etc.

You really don't have guaranteed control over this unless say you happen to build your own BIOS and OS Kernel, and can kill off SMMs/SMIs to ensure real-time code executes properly. gently caress knows what Windows does with them, it's been awhile since I've had windbg or similar attached to a machine.

movax fucked around with this message at 07:11 on Nov 1, 2012

Opinion Haver
Apr 9, 2007

Why are we talking about this anyway? We don't even know how accurate Sylink needs the count to be.

raminasi
Jan 25, 2005

a last drink with no ice

Boz0r posted:

No assumptions, sadly. It's just a bunch of 2D points with a pointer to the one on the right.

Can you assume that none of the edges cross each other? How about that the linked list is even circular (and not weird, like a p-shape)?

e: and this is the kind of question where you'll get perfectly fine results from just googling "polygon clockwise test" and "point in polygon test"

Adbot
ADBOT LOVES YOU

movax
Aug 30, 2008

yaoi prophet posted:

Why are we talking about this anyway? We don't even know how accurate Sylink needs the count to be.

Huh I went back and read his original post, setting up a 100Hz timer should be pretty trivial, I assume Python has some Timer class or similar in it. I don't know how demanding 100Hz timer + whatever executes every 100Hz would be interpreted by Python though, I've only written Python scripts that move files around :shobon:

From doing similar stuff on x86+Linux though, just leveraged the fact that kernel was already patched with Xenomai and used their real-time task/timer management services.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply