triangle

Traversing the boundary points of a polygon made of connected triangles

Hello I have a two dimensional polygon mesh made of connected triangles represented like this: vertex array: V = A, B, C, D, E, ... index array, triangle vertex indices in groups of 3 in counter-clockwise-order: I = 0, 4, 3, ... (so that e.g. V[0], V[4], V[3] which is A-E-D forms a triangle) Example mesh Now i want to traverse ...

Java: calculating area of a triangle

import java.lang.Math; import java.awt.* public class Triangle implements Shape { java.awt.Point a; java.awt.Point b; java.awt.Point c; public Triangle(java.awt.Point a, java.awt.Point b, java.awt.Point c) { this.a = a; this.b = b; this.c = c; } public double getArea( ) { do...

3D: write function to find configuration of a triangle

In 3D space, given P1 and P2, and two links attached end to end with lengths L1 and L2 respectively, link1 starts at P1. Write a function that finds the configurations of the links that put the 2nd link’s end at point P1. I dunno where to start... What exactly "link configuration" should be (as output): A vector (like 2i -3j+5k)? Or a...

How to make a Cocoa Disclosure Triangle

I have most of the code that works [self.disclosureButton setBezelStyle:NSDisclosureBezelStyle]; [self.disclosureButton setButtonType: NSPushOnPushOffButton]; [self.disclosureButton setTitle:nil]; [self.disclosureButton highlight:NO]; However, when I press the button, it turns black to indicate the press. How do I get it to stop chang...

How to check if a point (int - Coordinates) is within the hypotenuse of a triangle

I've got a right triangle and I want to check if a given point is on the Hypotenuse of that triangle. All points are plain integers, not floating-point variables. Edit: All green squares would be on the hypotenuse, the white squares not. I know x, y, the Coordinates of the Corners and the Coordinates of the Point I want to test. All Co...

How do I draw a texture-mapped triangle in MATLAB?

I have a triangle in (u,v) coordinates in an image. I would like to draw this triangle at 3D coordinates (X,Y,Z) texture-mapped with the triangle in the image. Here, u,v,X,Y,Z are all vectors with three elements representing the three corners of the triangle. I have a very ugly, slow and unsatisfactory solution in which I (1) extract a...

How to identify subtriangle within a rectangle given a coordinate in that rectangle

Given a rectangle of width w and height h. and a coordinate x,y in that rectangle I would like to identify which triangle I am within. i.e. the function should take parameters(x,y) and return a,b,c,d or a zero based number representing that triangle index i.e. (0=A,1=B,2=C,3=D) if they are in that order. I think this would be somethi...

How do I make a triangle space with text written for the iPhone?

I want to draw a triangle and elide text in the shape. I can restrict the triangle to an equilateral triangle and a fixed orientation ('upside down' or 'upside up'). Then I want to insert arbitrary text in the triangle such that the eliding is on word boundaries and not clipped. Any simple algorithms? What methods are available in Ob...

how do i display the coordinates of a random triangle in actionscript 2.0?

Hi I wanna generate a random triangle with coordinates, which shows the arcs of each corner in actionscript 2.0 with flash 8.0. Thanks in advance ...

how do i display the coordinates of a random triangle in a graph which ranges from +10 to -10 XY axis in actionscript 2.0?

Hi how i display the coordinates of a random triangle in a graph which ranges from -10 to +10 in XY axis with the points like A(2,1) etc with arcs in each corner, in actionscript 2.0 ...

circles and triangles problem

Hello everyone, I have an interesting problem here I've been trying to solve for the last little while: I have 3 circles on a 2D xy plane, each with the same known radius. I know the coordinates of each of the three centers (they are arbitrary and can be anywhere). What is the largest triangle that can be drawn such that each vertic...

After Effect - Triangle Wave (JavaScript)

Hi, I'm trying to control a parameter with AE expressions and I need a triangle wave. I've got this so far: freq = 20; amplitude = 8; m = amplitude; i = time*freq; m - (i % (2*m) - m); Unfortunately this gives a saw wave (see below) and my math's a bit rusty, any takers? Thanks! PJ http://i25.photobucket.com/albums/c73/pjburnhi...

Align the coordinate labels of the triangles, so that they never collide with each other. Actionscript 3

Hi all, Im trying to achieve something similar to the flash movie in the below link. http://mathopenref.com/coordtrianglearea.html As we drag the points of the triangle, the coordinates labels, ( A(1,2)) are properly aligned and arrange themselves so that they never collide with each other and never falls inside the triangle. Please ...

Detection of Triangle Collision in 2D Space

How can I programatically detect whether or not two triangles touch each other, given their vertices on a 2D coordinate plane? This includes touching points or edges, as well as if one triangle is completely "inside" the other one. ...

How to find coordinates of a 2d equilateral triangle in C ?

Hello, I have the coordinates (x,y) of 2 points. I want to build the third point so that these 3 points make an equilateral triangle. How can I calculate the third point? Thank you ...

Fastest way to compute point to triangle distance in 3D?

One obvious method for computing the minimum distance from a point to a 3D triangle is to project the point onto the plane of the triangle, determine the barycentric coordinates of the resulting point, and use them to determine whether the projected point lies within the triangle. If not, clamp its the barycentric coordinates to be in t...

2D polygon triangulation

The code below is my attempt at triangulation. It outputs the wrong angles (it read a square's angles as 90, 90. 90, 176) and draws the wrong shapes. What am I doing wrong? //use earclipping to generate a list of triangles to draw std::vector<vec> calcTriDraw(std::vector<vec> poly) { std::vector<double> polyAngles; //get angles ...

MATLAB - Triangle inside a delaunay mesh

I need your help in MATLAB for constructing a shape. First I need to draw a triangular mesh ( delaunay). I would like to generate an inscribed triangle in each triangle of this mesh in such a way that the distance between the inscribed and mesh triangle lies between 0-1 ( using normal or lognormal distribution)... So far I used the fol...

Help with Triangle collision detection in Obj-C

I haven't taken any advanced math courses or anything (I'm still in high school) and I just don't really understand all the triangle collision systems online. I have two triangular objects in a 2D space. How should I write Obj-C code so that a collision/intersection between the two can be detected? I'm stumped. ...

How to Print a Triangle using single variable and in a single loop?

A colleague ask me to print a triangle (of any shape) using a single variable and in a single loop. I do it this way: Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Triangle { class Program { static void Main(string[] args) { var triangle ...