Calculate scale portion in cocos2d - cocos2d-iphone

As you see on the image above, I have 2 rectangles. The yellow rect is scaled from the red one.
I know width, height and crossline(c) of the red and the yellow we only know the crossline
so : How can I know the scale portion, width height of the yellow rect.
By the way, I use this to make a program that I have eight point for touch & drag to transform the sprite. anyone have example code or sth let me know

First, determine the scale ratio: Scale ratio = Crossline of Yellow / Crossline of Red.
then use it to find sides:
Width of yellow = width of red * scale ratio
Height of yellow = height of red * scale ratio

Related

Negate Image Without gray Overlapping

Image negative effect is typically done like this:
pixel = rgb(1, 1 ,1) - pixel
but if the pixel color is close to gray, than:
pixel = rgb(1, 1, 1) - rgb(0.5, 0.5, 0.5) = 0.5
That's not a problem and it's how it should be, but for me it is, I am making a crosshair texture in my 3D game, which will be drawn in the center of the screen and I want it to have negative effect, reason for it is clearity, if I were to make crosshair white, it would not be visible when looking on white objects (I know I can make it with black outline so it is visible, but thats ugly), but it still has problems for grayish colors as I described, what can be done to fix that?

Intuition on YOLO bounding box width & height normalization formula

I found an article on how to compute yolo bounding box coordinates: x, y, width, height
http://christopher5106.github.io/object/detectors/2017/08/10/bounding-box-object-detectors-understanding-yolo.html
I dont understand what is the idea and intuition behind this computation? How does this lead to width and height be normalized to (0,1) relative to the original image?

Measure actual size of object in image given pixel dimension and distance from camera

I'm working with computer vision application, and I need to know the actual size (height) of object in image given the pixel height and the distance from camera.
I have this setup:
the black circle in left is the object with known height of 2cm, having 18cm distance from the camera (color red). Using the Y-component of bounding rectangle I got the pixel height of object which is 50px.
On the second setup I placed the object closer to camera:
and I got 50px in height. I know that the relationship between the distance and height is inversley proportional. But given this information, i cannot connect these numbers to acquire the actual height of unknown object to be placed like this:
The distance from the camera is not fixed, I need to know the actual size given the distance and pixel height.
any idea ??? please help me .. Thank you
BTW
can i use this???
say:
y = actual height, x = pixel height, z = distance
the relationship would be : y = xz/k
is it right ?

Multiple textures on one polygon OpenGL

So I have no idea how I should be doing what I want do so I'll explain as best as I can.
http://i.stack.imgur.com/j65H8.jpg
So imagine that entire image is a 2d square 128x128 and each color I want to apply a texture to that part of the 2d square. Also I want it to stretch as well so Red, Aqua, Green and Purple never stretch in any direction but Pink stretches all directions and then Grey, Yellow, Black and Orange stretch in the longest direction (grey/orange = width expands, yellow/black = height expands). When stretched it should look like this:
http://i.stack.imgur.com/wJiKv.jpg
Also I am using C++.

Opengl: fit a quad to screen, given the value of Z

Short Version of the question:
I will put a quad. I know the width and height of the screen in window coordinates, i know the Z-coordinates of the quad in 3D. I know the FOVY, I know the aspect. The quad will be put along Z-axis, My camera doesn't move (placed at 0, 0, 0). I want to find out the width and height of the quad IN 3D COORDINATES that will fit exactly onto my screen.
Long Version of the question:
I would like to put a quad along the Z-axis at the specified offset Z, I would like to find out the width and height of the quad that will exactly fill the entire screen.
I used to have a post on gamedev.net that uses a formula similar to the following:
*dist = Z * tan ( FOV / 2 )*
Now I can never find the post! Though it's similar, it is still different, because I remembered in that working formula, they do make use of screenWidth and screenHeight, which are the width and height of the screen in window coordinates.
I am not really familiar with concepts like frustum, fov and aspect so that's why I can't work out the formula on my own. Besides, I am sure I don't need gluUnproject (I tried it, but the results are way off). It's not some gl calls, it's just a math formula that can find out the width and height in 3D space that can fill the entire screen, IF Z offset, width in window coordinates, and height in window coordinates, are known.
Assuming the FOV is measured in Y-Z plane, then:
Height = Z * tan(fov/2)
width = height * aspect_ratio