Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:48:31+00:00 2026-06-12T11:48:31+00:00

I am not so worried about how to interpret how to draw the triangles,

  • 0

I am not so worried about how to interpret how to draw the triangles, but I have been trying to find how to find the indices for triangle knowing only the sides, and incenter of the triangle.

Some sample triangle inputs:

Side 1: 20
Side 2: 30
Side 3: 40
about x=100, y=400

Side 1: 20
Side 2: 40
Side 3: 50
about x=300, y=400

Myself, and a couple of other people, have been wracking our brains for the past 4 hours to no avail, so, any hint would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:48:32+00:00Added an answer on June 12, 2026 at 11:48 am

    What you first need to figure out is the positions of each corner. As you have the length of each side you could use the law of cosines…

    law of cosines

    …to get the angle between side 1 (a) and side 2 (b):

    angle

    The positions of the triangle corners are:

    • a) [0, 0]
    • b) [b, 0]
    • c) [c * cos(angle), c * sin(angle)]

    After this you have a triangle originating from the wrong place as you want them to be drawn in the center of the triangle. Calculating that center of an triangle could be done in different ways, but here is one really simple one:

    centerX = (a.x + b.x + c.x) / 3
    centerY = (a.y + b.y + c.y) / 3
    

    You could then translate that point to the point of your choice!


    Here is some code that does what you want:

    static class Triangle {
        double a, b, c;
    
        public Triangle(double a, double b, double c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    
        public double aAngle() {
            return Math.acos(-(Math.pow(a, 2) - Math.pow(b, 2) - Math.pow(c, 2)) / (2 * b * c));
        }
    
        public Point[] triangle() {
    
            double angle = aAngle();
    
            Point[] p = new Point[3];
    
            p[0] = new Point(0, 0);
            p[1] = new Point((int) b, 0);
            p[2] = new Point((int) (Math.cos(angle) * c), (int) (Math.sin(angle) * c));
    
            Point center = new Point((p[0].x + p[1].x + p[2].x) / 3, 
                                     (p[0].y + p[1].y + p[2].y) / 3);
    
            for (Point a : p)
                a.translate(-center.x, -center.y);
    
            return p;
        }
    }
    

    Example usage:

    public static void main(String[] args) {
    
        final Triangle t = new Triangle(20, 30, 40);
        final Point translation = new Point(100, 400);
    
        JFrame frame = new JFrame("Test");
    
        frame.add(new JComponent() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
    
                Point[] p = t.triangle();
    
                g.translate(translation.x, translation.y);
    
                for (int i = 0; i < p.length; i++)
                    g.drawLine(p[i].x, 
                               p[i].y, 
                               p[(i+1) % p.length].x, 
                               p[(i+1) % p.length].y);
            }
        });
    
        frame.setSize(800, 600);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using SWFOBJECT to embed my flash content. I have been worried about
I am not worried about screen real estate. They have changed behavior and added
I have a question about Java style. I've been programming Java for years, but
I am not worried about functions defined by me, but built-in functions or esp.
Not quite sure how to go about describing what it is I'm trying to
Not sure how to ask this, but i'll give it a try: I have
I am not worried about whether this is in Winforms or WPF. Is there
I want to play an AVI video in my WInForm. I'm not worried about
I'm trying to present my notecards in a web app style. I'm not worried
I have read a lot about preventing race conditions, but typically with one record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.