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

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 guide me..
Thanks in advance.

in the example you gave, the textfield seems to be aligned outside the triangle on the angle bisection of the corresponding corner.
for the position in one corner, take the two vectors to the other corners. normalize them and then add them and normalize the resulting vector again. this gives you the vector v of the angle bisection in that corner. multiply the vector with a negative constant and add it to the corner, and you'll obtain a position p outside the triangle. finally, if the angle of v is between pi/2 and -pi/2 (pointing right) align the right border of the label to p, and the left border otherwise.
for simple vector calculations, please see flash.geom.Point.

Related

Why is the y axis inverted in the HTML DOM and in SVG?

The y axis instead of going upwards, goes downwards, whilst the x axis has the normal sense from left to right. Why?
It is one of the most annoying obstacles when doing the graphic part of a website because the geometry has to be recalculated, as the usual calculation as in the cartesian plane will be wrong. So, why does this happen? Is there a specific reason? Did they not notice that they were betraying traditional mathematics?

Finding coordinates of the circumference of circle in pygame

in pyGame, I drew 2 circles. 1 that is stationary and one that moves with the arrow keys. So, I want the moving circle to bounce back once it touches the stationary circle( I want it to bounce off the stationary circle not the window.)
To do that I need to find the coordinates of the circumference of the stationary circle. But I do not know the specific module. Can someone suggest a module or an alternate solution.
What you actually need is to find each circles center and radius, then check the distance between the centers, if the distance is less than or equal to the two radii then you know you have a collision. I'll give an example to help:
Say you have circle A, fixed at the point (0,0) with a radius of 5px.
Circle B is at (0,10) with a radius of 3px, which is moving towards the point (0,0).
So, at first we know the distance between the two centers ((0,0) and (0,10)) is 10px, and since 10 is less than 5+3 we know the two circles are not touching.
Now at some point circle B will get to the point (0,8), at this moment when we check the distance between the circles we will get 8, which is equal to 5+3, so we have a collision.
I don't know which libraries and functions you will need to do this, but hopefully this has helped you find the right thing to search for. Basically you need to get the centers, the radii and the distance between two points (the two centers).

Trying to determine the apparent bounding box of a rotated object using ActionScript 3

Say I have a MovieClip of a non-rectangular shape. For an example I've attached a file called Symbol1.png. In this attached file, I've rotated the symbol instance. Of course, this causes the bounding box to rotate as well.
Now say I place that rotated symbol instance inside another symbol. I've illustrated this in the attached file called Symbol2.png. Note that the bounding box now includes the overhanging corners of the rotated symbol that is inside.
Is there any practical way to determine the apparent bounding box of Symbol2 without including the corners of Symbol1's bounding box? I'm trying to zoom and rotate to an automatically calculated size and angle, but this overhang problem is causing a lot of extra space to be included in my final zoomed perspective.
Thanks.
Every container's bounding region is defined by the space that its children occupy. What you're looking for isn't the "bounding box" per-say (as Flash is accurately representing this), but rather the visible space the children occupy (which is much harder to quantify).
Thankfully, you're not the first to ask this, and (technically) this is a duplicate of Calculate Bounding box coordinates from a rotated rectangle

AS3 spin text around center?

I am trying to get an effect like this:
http://www.welcomeanimations.com/welcome_animated_gifs_rotating_sign_orange_chrome_k_1.htm
I have tried all sorts of things:
Matrix translation/rotation - spins the text around the 'Z' axis, instead of 'Y'
Adding TextField to a sprite, and Sprite.rotationY++: reg. point is upper left corner
Adding to MovieClip - same as above (an article said MovieClip's reg. point was centered).
This should be trivial?!?! Help me stackoverflow, you're my only hope!
So you have to remember, Display objects scale and rotate around their local coordinate system. so when you put a textfield in a sprite, you need to center it in that sprite's coordinate system. And doing that for textfields is annoying because their width/height isn't always accurate but there is trick for that: get visual bounds, but normally you can take half of somethings width and height
I've created a prototype for you on wonderfl so you can see the solution working in action. Click on the blue square to see how the local coordinate system messes with the rotation
Finally as you use thing you might find things not rotating in 3D space quite right, this should be able to fix that.

Setting movieclip origin with AS3

I have a spotlight that moves on a stage.
Now I rotate the spotlight but its not rotating on the correct point/origin.
I am trying to do something like
myOject.setOrigin = {x , y};
//and then rotate it about x,y.
I have manually set the white circle in the correct place and when I rotate the
object with the mouse on the screen it works.
Can somebody help me?
Make sure the registration point is in the middle of your symbol. It's not the white circle that appears when you use the Free Transform Tool:
But the crosshair that appears when you edit your movie clip:
You can easily center the object by selecting everything, then opening the Align panel and aligning its horizontal and vertical axes to the center using the two "center" icons under the Align section. If your MC has multiple items per layer, group each layer before aligning, then ungroup after aligning:
The white circle is not what will be used as the origin, it's the little cross. Adjust your clip to have that in the center (you'll have to move all of it's contents). Another option, if moving is not possible, is to wrap your clip in another clip and move it within that.
Select symbol and click CTRL+E - Then move it to positioning cross.