Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 04-07-07   #1 (permalink)
Intel Overclocker
 
cgrado's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Sugar Land, Texas
Posts: 4,965

Rep: 229 cgrado is acknowledged by manycgrado is acknowledged by manycgrado is acknowledged by many
Unique Rep: 175
FAQs Submitted: 1
Folding Team Rank: 254
Hardware Reviews: 1
Trader Rating: 1
Default Triangle Class

Whoo! For class i had to make a triangle class which takes in either SSS or SAS and calculates the other sides and angles. I finally did it.

get and set methods for all instance variables as well as getArea and drawTriangle.

Code:
import TurtleGraphics.StandardPen;
public class Triangle
{
    private double base, side2, side3, side1;
    private double height, angle1, angle2, angle3;
    //SAS works!
    public Triangle(double s1, double a3, double s2, String sas)
    {
        side1 = s1;
        side2 = s2;
        angle3= a3;
        side3 = Math.sqrt((s1*s1)+(s2*s2)-2*s1*s2*(Math.cos(Math.toRadians(a3))));
        angle2=Math.toDegrees(Math.asin(s2*(Math.sin(Math.toRadians(a3)))/side3));
        angle1=180-(angle2+angle3);
        base=0;
        height=0;
        
        
    }
    //It works!
    public Triangle(double s1, double s2, double s3)
    {
        side1 = s1;
        side2 = s2;
        side3 = s3;
        angle1= Math.toDegrees(Math.acos( ((s1*s1)-(s2*s2)-(s3*s3))/(-2*s2*s3) ));
        angle2= Math.toDegrees(Math.acos( ((s2*s2)-(s1*s1)-(s3*s3))/(-2*s1*s3) ));
        angle3= Math.toDegrees(Math.acos( ((s3*s3)-(s1*s1)-(s2*s2))/(-2*s1*s2) ));
    }
    public double getBase()
    {
        return base;
    }
    
    public double getSide1()
    {
        return side1;
    }
    
    public double getSide2()
    {
        return side2;
    }
    
    public double getSide3()
    {
        return side3;
    }
    
    public double getHeight()
    {
        return height;
    }
    
    public double getAngle1()
    {
        return angle1;
    }
    
    public double getAngle2()
    {
        return angle2;
    }
    
    public double getAngle3()
    {
        return angle3;
    }
    
    public double getArea()
    {
        double s = 0.5*side1*side2*side3;
        double area = Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
        return area;
    }
    

        
    public void drawTriangle()
    {
        double sideOne = this.side1;
        double sideTwo = this.side2;
        double sideThree = this.side3;
        double angleOne = this.angle1;
        double angleTwo = this.angle2;
        double angleThree = this.angle3;
        StandardPen pen = new StandardPen();
        pen.move((int)sideOne*100);
        pen.turn(180-angleThree);
        pen.move((int)sideTwo*100);
        pen.turn(180-angleOne);
        pen.move((int)sideThree*100);

        
    }
    
    public String toString()
    {
        String str;
        str = "side1 = " +side1+ " \n" + "side2 = " +side2+ " \n" + "side3 = " +side3+ " \n" +"angle1 = " +angle1+ " \n" +"angle2 = " +angle2+ " \n" +"angle3 = " +angle3+ " \n" +"base = " +base+ " \n" +"height = " +height+ " \n";
        return str;
    }
}
__________________
Quote:
Originally Posted by TwIsTeDbOi View Post
What's next, banning mirrors because, oh no god forbid, if we see ourselves naked we're gunna be traumatized?
I'm like the inquirer, take everything i say with a grain of salt.
SLi Zone PSU listing- check to see if your PSU is SLi certified.
BF2 stats BF2142 stats
My Guide to BF2 Unlocks

System: Immortal
CPU
E6600 44G 3.240GHz
Motherboard
Asus P5B-deluxe
Memory
2GB PQIturbomem 667(800mhzballistix soon)
Graphics Card
eVGA 8800GT (650/950)
Hard Drive
1x 400GB Seagate 7200rpm/16mb cache
Sound Card
X-fi Xtremegamer
Power Supply
610w PCP&C silencer
Case
TTArmor w/side fan
CPU cooling
Custom Watercooling
GPU cooling
Stock EVGA
OS
Windows XP Home/Ubuntu
Monitor
NEC MultiSync LCD1970GX

Last edited by cgrado : 04-15-07 at 12:28 AM.
cgrado is offline I fold for Overclock.net cgrado's Gallery   Reply With Quote
Old 04-07-07   #2 (permalink)
Jack of all trades
 
H3||scr3am's Avatar
 
intel nvidia

Join Date: Mar 2007
Location: Cambridge, Ontario
Posts: 3,563

Rep: 271 H3||scr3am is a proven memberH3||scr3am is a proven memberH3||scr3am is a proven member
Unique Rep: 208
Trader Rating: 2
Default

very nice, I love the detail in your PI, too much superpi?
__________________

I am 91% addicted to Counterstrike. What about you?
OCN CS:S GG: overclock.nuclearfallout.net:27015
OCN TF2: 8.9.16.94:27015 (temporary)
[CSS GUN GAME ADMIN] Ban Hamma of Pwnage +5 skillz
[TF2 ADMIN] Ban Hammer of scouting + 20 scout powaz

System: B3 Holds me back :(
CPU
Intel Q6600 (L664G)
Motherboard
Asus P5K Deluxe
Memory
G.Skill 2GB HZs & 2GB Ballistix
Graphics Card
eVGA GeForce 8800 GTX
Hard Drive
WD SATA HD 250GB
Sound Card
Auzentech X-Fi Prelude
Power Supply
Silverstone Decathlon 750W
Case
TT Armor w/ 25cm side fan
CPU cooling
D-Tek FuZion WB
GPU cooling
DD 8800 WB
OS
XP pro SP3 :D
Monitor
2x 21" Sony G400 CRTs
H3||scr3am is offline Overclocked Account H3||scr3am's Gallery   Reply With Quote
Old 04-07-07   #3 (permalink)
Intel Overclocker
 
cgrado's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Sugar Land, Texas
Posts: 4,965

Rep: 229 cgrado is acknowledged by manycgrado is acknowledged by manycgrado is acknowledged by many
Unique Rep: 175
FAQs Submitted: 1
Folding Team Rank: 254
Hardware Reviews: 1
Trader Rating: 1
Default

Quote:
Originally Posted by H3||scr3am View Post
very nice, I love the detail in your PI, too much superpi?
haha, i didn't even use it though. i just had it for some checking purposes against what the Math class uses. i should probably take it out.
__________________
Quote:
Originally Posted by TwIsTeDbOi View Post
What's next, banning mirrors because, oh no god forbid, if we see ourselves naked we're gunna be traumatized?
I'm like the inquirer, take everything i say with a grain of salt.
SLi Zone PSU listing- check to see if your PSU is SLi certified.
BF2 stats BF2142 stats
My Guide to BF2 Unlocks

System: Immortal
CPU
E6600 44G 3.240GHz
Motherboard
Asus P5B-deluxe
Memory
2GB PQIturbomem 667(800mhzballistix soon)
Graphics Card
eVGA 8800GT (650/950)
Hard Drive
1x 400GB Seagate 7200rpm/16mb cache
Sound Card
X-fi Xtremegamer
Power Supply
610w PCP&C silencer
Case
TTArmor w/side fan
CPU cooling
Custom Watercooling
GPU cooling
Stock EVGA
OS
Windows XP Home/Ubuntu
Monitor
NEC MultiSync LCD1970GX
cgrado is offline I fold for Overclock.net cgrado's Gallery   Reply With Quote
Old 04-12-07   #4 (permalink)
110100001101001111000
 
C-bro's Avatar
 
intel nvidia

Join Date: Jan 2006
Location: Hamilton, ON
Posts: 1,832

Rep: 283 C-bro is a proven memberC-bro is a proven memberC-bro is a proven member
Unique Rep: 215
FAQs Submitted: 6
Folding Team Rank: 237
Hardware Reviews: 9
Trader Rating: 1
Default

For computing area, getting the height would be fairly easy if you set up your sides properly. Start with a reference side. Subtract it's angle from all the sides, so you ensure that the reference side is horizontal, but the shape remains the same. Since the reference side is now horizontal, you know that you can trace either of the remaining sides to find the top point of the triangle. Your height is then simply h = length of trace side*sin(angle of trace side). Since you already rotated the reference side horizontal, the magnitude of your reference side gives you your base. And there you have all the elements for the area. Sound kind of confusing, but if you draw out a triangle on paper it becomes much more intuitive.

System: RAID0R
CPU
Intel E2180 3.33GHz
Motherboard
Asus P5K-E/WIFI-AP vMod
Memory
2GB Kingmax DDR2-1066
Graphics Card
EVGA 8800GT
Hard Drive
2x250GB WD+500GB 7200.11
Sound Card
SB Audigy 2
Power Supply
Corsair CMPSU-550VX
CPU cooling
Arctic Cooling Freezer 7 Pro
GPU cooling
Zalman VF900-Cu
OS
Windows Vista Business 32-Bit
Monitor
HP F2105 21" & Samsung 712N
C-bro is offline I fold for Overclock.net Overclocked Account C-bro's Gallery   Reply With Quote
Old 04-12-07   #5 (permalink)
Intel Overclocker
 
cgrado's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Sugar Land, Texas
Posts: 4,965

Rep: 229 cgrado is acknowledged by manycgrado is acknowledged by manycgrado is acknowledged by many
Unique Rep: 175
FAQs Submitted: 1
Folding Team Rank: 254
Hardware Reviews: 1
Trader Rating: 1
Default

thanks!
__________________
Quote:
Originally Posted by TwIsTeDbOi View Post
What's next, banning mirrors because, oh no god forbid, if we see ourselves naked we're gunna be traumatized?
I'm like the inquirer, take everything i say with a grain of salt.
SLi Zone PSU listing- check to see if your PSU is SLi certified.
BF2 stats BF2142 stats
My Guide to BF2 Unlocks

System: Immortal
CPU
E6600 44G 3.240GHz
Motherboard
Asus P5B-deluxe
Memory
2GB PQIturbomem 667(800mhzballistix soon)
Graphics Card
eVGA 8800GT (650/950)
Hard Drive
1x 400GB Seagate 7200rpm/16mb cache
Sound Card
X-fi Xtremegamer
Power Supply
610w PCP&C silencer
Case
TTArmor w/side fan
CPU cooling
Custom Watercooling
GPU cooling
Stock EVGA
OS
Windows XP Home/Ubuntu
Monitor
NEC MultiSync LCD1970GX
cgrado is offline I fold for Overclock.net cgrado's Gallery   Reply With Quote
Old 04-12-07   #6 (permalink)
Apple Doesn't Love You
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 4,975
Blog Entries: 1

Rep: 564 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 338
FAQs Submitted: 6
Trader Rating: 5
Default

There is an easier way. IIRC
d = sqrt(a^2+b^2+c^2)
A = sqrt((d-a)^2+(d-b)^2+(d-c)^2)

I'd look that up to chekc it
__________________
BIG BROTHER
I put on my robe and wizard hat...

IS WATCHING

System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 04-14-07   #7 (permalink)
110100001101001111000
 
C-bro's Avatar
 
intel nvidia

Join Date: Jan 2006
Location: Hamilton, ON
Posts: 1,832

Rep: 283 C-bro is a proven memberC-bro is a proven memberC-bro is a proven member
Unique Rep: 215
FAQs Submitted: 6
Folding Team Rank: 237
Hardware Reviews: 9
Trader Rating: 1
Default

Quote:
Originally Posted by rabidgnome229 View Post
There is an easier way. IIRC
d = sqrt(a^2+b^2+c^2)
A = sqrt((d-a)^2+(d-b)^2+(d-c)^2)

I'd look that up to chekc it
I believe you're thinking of Heron's formula, which is slightly different, but along the same lines.

d = 0.5*(a+b+c); // this is called the semiperimeter
A = sqrt((d*(d-a)*(d-b)*(d-c));

System: RAID0R
CPU
Intel E2180 3.33GHz
Motherboard
Asus P5K-E/WIFI-AP vMod
Memory
2GB Kingmax DDR2-1066
Graphics Card
EVGA 8800GT
Hard Drive
2x250GB WD+500GB 7200.11
Sound Card
SB Audigy 2
Power Supply
Corsair CMPSU-550VX
CPU cooling
Arctic Cooling Freezer 7 Pro
GPU cooling
Zalman VF900-Cu
OS
Windows Vista Business 32-Bit
Monitor
HP F2105 21" & Samsung 712N
C-bro is offline I fold for Overclock.net Overclocked Account C-bro's Gallery   Reply With Quote
Old 04-15-07   #8 (permalink)
Intel Overclocker
 
cgrado's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Sugar Land, Texas
Posts: 4,965

Rep: 229 cgrado is acknowledged by manycgrado is acknowledged by manycgrado is acknowledged by many
Unique Rep: 175
FAQs Submitted: 1
Folding Team Rank: 254
Hardware Reviews: 1
Trader Rating: 1
Default

Thanks, c-bro, i used that. I'll update the code.
__________________
Quote:
Originally Posted by TwIsTeDbOi View Post
What's next, banning mirrors because, oh no god forbid, if we see ourselves naked we're gunna be traumatized?
I'm like the inquirer, take everything i say with a grain of salt.
SLi Zone PSU listing- check to see if your PSU is SLi certified.
BF2 stats BF2142 stats
My Guide to BF2 Unlocks

System: Immortal
CPU
E6600 44G 3.240GHz
Motherboard
Asus P5B-deluxe
Memory
2GB PQIturbomem 667(800mhzballistix soon)
Graphics Card
eVGA 8800GT (650/950)
Hard Drive
1x 400GB Seagate 7200rpm/16mb cache
Sound Card
X-fi Xtremegamer
Power Supply
610w PCP&C silencer
Case
TTArmor w/side fan
CPU cooling
Custom Watercooling
GPU cooling
Stock EVGA
OS
Windows XP Home/Ubuntu
Monitor
NEC MultiSync LCD1970GX
cgrado is offline I fold for Overclock.net cgrado's Gallery   Reply With Quote
Old 04-15-07   #9 (permalink)
..the party can start now
 
Sideburns's Avatar
 
amd nvidia

Join Date: Jun 2005
Location: Windsor, Ontario
Posts: 8,143

Rep: 577 Sideburns is becoming famousSideburns is becoming famousSideburns is becoming famousSideburns is becoming famousSideburns is becoming famousSideburns is becoming famous
Unique Rep: 356
FAQs Submitted: 1
Trader Rating: 6
Default

dude...it's called trigonometry? lol...or am I missing something?
__________________
System: Desktop
CPU
Opteron 165 CCBWE0550UPMW
Motherboard
Asus A8N32-SLI Deluxe
Memory
2 x 512 Geil ONE TCCD
Graphics Card
Geforce 7900GT
Hard Drive
2 x 250GB DM10 (RAID-0)
Sound Card
SB Audigy 2 ZS
Power Supply
Seasonic S12-600HT
Case
Chieftec Dragon /w Window
CPU cooling
Thermaltake BigTyphoon
GPU cooling
Zalman VF900CU
OS
Windows XP Home SP2
Monitor
Dell 2007wfp 20.1" w/s
Sideburns is offline Overclocked Account   Reply With Quote
Old 04-15-07   #10 (permalink)
Rabble rabble
 
TwIsTeDbOi's Avatar
 
intel nvidia

Join Date: Oct 2006
Location: 29 Palms(stumps), CA
Posts: 2,305

Rep: 134 TwIsTeDbOi is acknowledged by manyTwIsTeDbOi is acknowledged by many
Unique Rep: 108
Trader Rating: 3
Default

Heh not bad man. I'm almost done with AP computer science and I'm still confused on a LOT of the Java language.
__________________
Quote:
Originally Posted by DuckieHo View Post
Your carbon fiber is probably turbostratic while you need heat-treated mesophase-pitch-derived carbon fibers for thermal conductivity.
"For a wounded man shall say to his assailant, 'If I live, I will kill you. If I die, you are forgiven.' Such is the rule of honor"
Overclock.net TOS: Live it. Love it.
THE CHEVY Owners CLUB!!!

System: Sony Vaio AR730
CPU
T8100
Motherboard
Sony
Memory
3GB DDR667
Graphics Card
8400GT
Hard Drive
2x 160GB
Sound Card
SigmaTel HD
Power Supply
The wall
Case
Laptop
CPU cooling
Laptop
GPU cooling
Laptop
OS
Vista Home Premium
Monitor
17" 1440x900
TwIsTeDbOi is offline Overclocked Account   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 02:05 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.32292 seconds with 8 queries