Centroid.EU Blog

(this blog is mostly encrypted - adults only)

Previous Page

A circle is more like a square

August 6th, 2020

No it's a rectangle! No it's two triangles!

I used squares in the past on my website to find out if someone clicked on a circle in a HTML canvas element. This works, but it's not very rounded. In fact the curves of the circle fall away and you're left with just a square. I tackled this problem yesterday once and for all, and after drawing this out I finally realised the answer.

It's not enough to measure the boundary of any dot within the area of a circle ,that is on a grid, All that is needed that you measure the distance between two points. M and P. Where M is the center of the circle and P any arbitrary point where you clicked. So then we analise, what is point P when M is (X1, Y1). P is really X1 - X2, Y1 - Y2 relative to M. And it forms a square or rectangle with one corner being M. Cut the rectangle in half you have two triangles. But not just any triangles they are right triangles. So we can apply Pythagoras theorem here because P could lie on R where line MP is the hypotenuse of the triangles (either). All we need now is to get the positive value of X1 - X2 and Y1 - Y2. Luckily computers have the abs() or fabs() function for that.

Pythagoras theorem said: A^2 + B^2 = C^2. So we can make our formuala now:

P = sqrt(pow(fabs(Y1 - Y2), 2.0) + pow(fabs(X1 - X2), 2.0));
And if P is less or equal to the Radius of the circle, then P lies in the circle.

So I have written a small C program to double check this and it works. The point M in the program is at coordinates 20, 20 and you enter x, y of P and the radius of the circle, and it will tell you if it's inside or outside of the circle.


#define CIRCLE_X        20.0
#define CIRCLE_Y        20.0

main(int argc, char *argv[])
        double x1 = CIRCLE_X, x2;
        double y1 = CIRCLE_Y, y2;

        double p, r;

        if (argc != 4) {
                fprintf(stderr, "usage: prog x-coord y-coord radius\n");

        r = atof(argv[3]); y2 = atof(argv[2]);
        x2 = atof(argv[1]);
        p = sqrt(pow(fabs(y1 - y2), 2.0) + pow(fabs(x1 - x2), 2.0));

        if (p <= r) {
                printf("With the centroid of a circle at %f, %f coordinates,"
                        " you clicked inside the circle\n", CIRCLE_X, CIRCLE_Y);
        } else {
                printf("With the centroid of a circle at %f, %f coordinates,"
                                "you did not click inside the circle\n",
                                        CIRCLE_X, CIRCLE_Y);

                exit (1);

	exit (0);

So in any case a circle is just a square, true. No it's just a rectangle, also true, no it's two triangles, absolutely also true! I manage this on mediocre math skills, but it took a lot of thinking and visualizing it on a piece of paper that's a grid. If anyone has a better formula for this I'd love to see it! Open Mathematics!

PS: I have made a little game with javascript. If you click on the circle it will change colour, if you miss it it won't. Perfect trial for my formula.


The 2018 Sabotage in Cornfields

August 5th, 2020

Around here, there was sabotage in corn fields around 2018. This is summed up here (german) by mainpost.de. Although they were able to get DNA data and matches, this is not a preventative from damage and someone possibly getting hurt during harvest.

So I was wondering. Would one of those consumer drones (DJI or otherwise) be able to be used to scan the field with a metal detector? Has someone done anything similar? I guess someone could program a path based on GPS for the drone to fly over the field, and someoen else gets GPS data and metal detector signal which gets digitized (on the drone either by a soundcard sampler or otherwise). I guess these sweeps for metal can be done at night too, just before a harvest. Software needs to be written for this, the idea is out there.


Today is supposed to be hottest day of the year

July 31st, 2020

We're expecting temperatures upwards of 38C in .de. This is a lot. Currently at the Eselshoehe Wetterstation in Schweinfurt it is 16.6C so still relatively cool. But it is also 8:17AM.


I have picked my project theme

July 31st, 2020

For the prototype fund (9th round) I have finalized what my project is going to be about.

It will be improvements for delphinusdnsd like I mentioned before, but I have a concrete picture of what I must do. I'm going to make delphinusdnsd an authoritative nameserver for replacing Microsoft DNS server. For that I need to do a few things: GSS-TSIG (RFC 3645), it comes with several depended RFC's that I also have to implement like TKEY (RFC 2930) and possibly KEY RR which comes with the SIG(0) RFC. Also I'm going to implement DNS Updates after RFC 2136 and RFC 3007 (secured), and if there is time left in the project time (6 months) I'll try to implement auto-signing updated records (DNSSEC).

This is all a big task, and there is always the hindthought that Microsoft Active Directory won't allow this. I have found a document from Bluecat Networks that they can do this (on a BIND9 basis). So this will be my outline that I will be working/striving towards. Wish me luck, I'm applying tomorrow, most likely.


Removed CVSweb from my servers

July 28th, 2020

The day had to come, I'm thinking. If you were browsing my CVS repo on my site I have replaced it with a GOT repo. I will reinstitute most software on GOT when I can. CVSweb didn't do it for me anymore when it stopped displaying commits to a branch. I will continue using the CVS without a web interface until the delphinusdnsd 1.5.0 release at which point I'll likely switch completely to got/git. Sorry for any inconvenience if you were going through my repo, just at this time when I removed it.


DMARC enabled

July 26th, 2020

I have enabled dmarc default policy (none) on this zone centroid.eu.

_dmarc.centroid.eu.     3600    IN      TXT     "v=DMARC1; p=none;"
The TTL is still lower than I'd like but I'm gonna watch this for a while and then raise it. Basically what happened is that remote mail sites would look this up with dnssec enabled and get an NXDOMAIN with proof-of-nonexistence which is 850 odd bytes, this default reply is only about 66 bytes and I'll be happier posting to mailing lists, I think.

Here is a sample NXDOMAIN summary to show you it is a lot of bytes:

;; Query time: 0 msec
;; WHEN: Sun Jul 26 07:53:40 CEST 2020
;; MSG SIZE  rcvd: 850
Here's hoping I didn't make a calculated mistake.


Going to try to reapply to the Prototypefund.DE this August

July 17th, 2020

When I applied to round five of the prototypefund I was in good spirits. Then I was turned down in November 2018, it sorta pissed me off. But I'm going to re-apply again this August for the ninth round. I'm gonna try to get funding for this and help me get DNS Updates into delphinusdnsd, and best of all get paid for it. Since the funding is only for half a year starting in January, I'll have less time than allotted for delphinusdnsd 1.6.0. So I'll have to work twice as good/fast. You can research backwards to my original mention of this in this blog by searching for "prototypefund" I had six hits. The website of the prototypefund.de is here.


Interesting article at the BBC

July 17th, 2020

I know what it feels like to be working when it's way hot, and having no aircon. Here is an article at the bbc, that has an interesting chart of temperature rise since 1850. It looks to me that since 1975 the line has been going straight up. WW2 is evident too, and by extension to the first line that goes straight up one can draw a line from 1900 and it is similar sloped. The industrial age has hurt us, how/when can we make amendments?


I replaced 15 year old code today

July 16th, 2020

Story is at DelphinusDNS.org blog. It's amazing the code has held so long, even though it was bogus.


News from delphinusdnsd

July 12th, 2020

Since I got a blog for delphinusdnsd I never talk about it here, so here is some updates.

  1. 1.4.2 was released last week
  2. This month I'm putting forwarding (with semi-caching) functionality in it
  3. The last quarter of this year I'm gonna start the daunting task of adding dynamic updates to it
The 1.5.0 release is expected to drop in December of this year. It will be better than ever (every release gets better). I'm working toward the 1.6.0 release with dns updates, so that I can start a business around dynamic dns updates in 2022. It would be homegrown technology not something you get off a shelf. I'm hoping to be making a bit of money with this, which is alright since currently I'm once again on hard times.


Next Page


RSS Feed

Click here for RSS

On this day in

Other links

Have feedback?

By clicking on the header of an article you will be served a cookie. If you do not agree to this do not click on the header. Thanks!

Using a text-based webbrowser?

... such as lynx? Welcome back it's working again for the time being.

Older Blog Entries

Powered by BCHS