faulty triangle funct
Displaying 1-12 of 12 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
RageCage

leave it to me to find the most obscure geometric problems.



I'm using rays of thin triangles to produce a circle(you'll find out why soon enough, this is not supposed to be a geometric circle algorithm or anything).

Unfortuneately, the triangles seem to screw up when they're in a certain range of length. What is shown in the graphic above is a circle produced with a single radius and above that is the same thing only with the radius decreasing as it produces the circle.

any ideas why it gets all cracky?

Posted on 2004-07-09 07:08:24

RageCage



Here's the same thing at a constant radius of 100.

x,y=origin;
x2,y2=target position;
c=distance between xy & x2y2;

x3=(c/56)*cos(ang-90)/65536+x2;
y3=(c/56)*sin(ang-90)/65536+y2;

x4=0-(c/56)*cos(ang-90)/65536+x2;
y4=0-(c/56)*sin(ang-90)/65536+y2;

triangle(x,y,x3,y3,x4,y4,0,screen);


56 is a constant that I figured out. Every 56 pixels, the width between two lines doubles. Thus every 56 pixels you would increase the thickness of a line a little.

it does work most the time but I need to to work all the time. I assume its something with triangle() but maybe I'm just stupid.

Posted on 2004-07-09 07:20:07 (last edited on 2004-07-09 07:22:01)

Zip

Hmm... Do you really have to draw the circle like that? I think I tried a similar thing in ogl and had similar odd results. In the end I effectively just drew the trianlges the other way round, with the base on the edge and points in the middle and it worked fine. Slightly funky code below (it was for finding the edge of a circle from any point).

(x1, y1) is the center, rz the radius, deg is lying and is in fact in radians
glBegin(GL_TRIANGLE_STRIP);

glVertex3f( x1, y1, z);
for (float deg=0; deg < 2*3.14f; deg += 0.1)
{
glColor3f(0.0f,deg/7.0f,0.0f);
glVertex3f( rz * cos(deg), rz * sin(deg), z);
glVertex3f( rz * cos(deg+0.1f), rz * sin(deg+0.1f), z);
glVertex3f( x1, y1, z);
}
glEnd();


Zip

[Edit: Blasted < got me twice]

Posted on 2004-07-09 07:47:11 (last edited on 2004-07-09 07:51:45)

Omni

I think the V3 Docs said there is an imperfection in the triangle algorithm...I think it also said they have no really motivation to fix it.

Why don't you just use Lines instead?...wait...to fill the gaps between the lines...

Hmm. Don't think I can help. Sin and Cos: Programmer's Pals (which I have bookmarked) has a circle drawing algorithm that uses Pythagorean theorum to achieve a solid circle, which might could then be used with Line to fill it in, but I'm not sure if that's what you're looking for...

Posted on 2004-07-09 14:33:07

RageCage

It needs to be from the middle out.

I guess I'll just have to make my own triangle algorithm...

Posted on 2004-07-09 18:49:42

Omni

Are you using any type of lucency?

Perhaps if there are slight imperfections in triangle drawing, overlapping pixels with lucency will destroy the integrity of a solid circle.

or...make your triangle algorithm with some Lines...it doesn't seem too hard.

Posted on 2004-07-10 03:27:35 (last edited on 2004-07-10 03:28:27)

Gayo

Yeah, the triangle drawer is shit. I made one that seems to work better, but it's agonizingly slow, so I don't plan to actually use it.

Posted on 2004-07-10 04:44:29

RageCage

when and if I find one thats fast and able, I'll release it ^_^

Posted on 2004-07-10 05:06:05

vecna

I'm not understanding why you're not using lines. ... Or just circlefill for that matter.

I wouldn't exactly say the triangle filler is faulty... its not an anti-aliasing triangle filler, so when the triangle 'width' drops below 1 pixel or half or something, it stops drawing. and since its integer math, this sort of behavior is expected.

It just wasn't designed as a line-drawer.

Posted on 2004-07-10 16:23:57

RageCage

Gah, I'm sorry... I figured out what was wrong... go on about yalls buisness =p

Posted on 2004-07-10 17:47:26 (last edited on 2004-07-10 17:58:24)

Gayo

What exactly are you *doing*, anyhow?

Posted on 2004-07-12 15:32:19

RageCage

http://www.verge-rpg.com/boards/display_thread.php?id=17097

Posted on 2004-07-13 00:21:09


Displaying 1-12 of 12 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.