Visio custom circle where diameter is calculated from control distance - visio

I'm trying to figure out how to create a custom circle shape in Visio using the ShapeSheet to dynamically calculate the diameter of the circle relative to a control point.
The control point is essentially the vertex of an isosceles triangle and the diameter of the circle is calculated as the base of the isosceles triangle using a user variable for the angle of the vertex of that isosceles triangle.
The effect is the further you drag the control point away from the circle, the larger the circle gets, but the constant 'angle' of the vertex affects the rate that the circle would grow.
I know the trig for this diameter=2*control_distance*tan(vertex_angle/2) but since a circle isn't a fundamental shape in Visio (rather an ellipse is), I don't know how to accomplish calculating a circle with a shape sheet.

Related

How to position and scale a triangular model by knowing its vertices in Unity3d

I want to position different equilateral triangular models, in a 3d space in unity. The problem is that the 3 known vertices aren't equilateral triangular, some of them aren't even isosceles so I need to wrap my model to match it's corners to the given vertices.
I would like to model those triangles different from each other that's why want to use pre-created models.
Currently I do the following calculation to position and scale the triangles onto a isosceles triangle:
Middle-point of the given 3 vertices
Vector3 middlepoint = (points[0]+points[1]+points[2])/3;
Distance from Middle-point
pointdistance[i] = Vector3.Distance(points[i],middlepoint);
The closest point is the one I will rotate the triangle to, so I know the triangles height (y-Axis), let's say the corner point is points[0] so float height = Vector3.Distance(points[0],middlepoint);
(I'm certain this step is wrong for a non isosceles triangle) I calculate it's width by determining the circumscribed circle radius, with the help of the remaining points
float width = (float)(Vector3.Distance(points[1] , points[2])*Math.Sqrt(3)/3);
Apply the scale to the model
float scale = new Vector3(height,width,1);
I calculate the normal normalVec of those 3 points to get the x and y orientation right, this works well so i think I don't need to change it
Instantiate the triangle
this.Triangle = (GameObject)Instantiate(standardTriangleModel,middlepoint, Quaternion.LookRotation(normalVec,points[0]));
The result looks pretty good until the triangles are not isosceles anymore
(Blue line = middlepoint to closest point, Green lines = connection between the given vertices)
So does anyone have a clue how i could position and resize my triangular models to match those points?
No code as I don't have unity handy at the moment. This answer is based on how to shear using unity gameobject transforms by trejkaz on the Unity Q&A site.
Start with gameobjects that are a right triangle of height and width 1:
Then for Triangle ABC, Set the X scale of the right triangle gameobject (which we can call mainObject) to be the length of AB, and set the Y scale to be the shortest distance between C and the line that travels through AB (the height of the triangle measured from the base AB).
Consider the angle CAB = θ.
Then, put mainObject inside of a parent gameobject called Outer1. Scale Outer1 with Y=sqrt(2)/sin(90-θ), X=sqrt(2).
Then, put Outer1 inside of a parent gameobject called Outer2. Rotate Outer2 around mainObject.forward by (θ-90) (which should be a clockwise rotation of 90-θ).
Then, put Outer2 inside of a parent gameobject called Outer3. Scale Outer3 with Y=sin((90-θ)/2), X=cos((90-θ)/2).
At this point, mainObject should be sheared and scaled into the correct shape. You will just need to position and rotate Outer3 so that the (pre-shearing) right angle corner of mainObject is at A,mainObject.right points from A to B, and mainObject.forward points normal to the triangle.

Rotate vertices selected using weight map on UVs in Unity3D's Shader Graph around pivot point

TLDR: Can't figure out the correct Shader Graph setup for using UV and vertex displacement to cheaply animate a (unrigged) mesh.
I am trying to rotate a part of the mesh based on the UV coordinates, e.g: fromX 0 toX 0.4, fromY 0 toY 0.6. The mesh is created uv-mapped with this in mind.
I have no problem getting the affected vertices in this area. Problem is that I want to rotate these verts for customizable axis e.g. axis(X:1, Y:0, Z:1) using a weight so that the rotation takes place around a pivoted point. I want the bottom selection to stay connected to the rest of the mesh while the other affected vertices neatly rotate around this point.
The weight can be painted by using split UV channels as seen in the picture:
I multiply the weighted area with a rotation node to rotate it.
And I add that to the negative multiplied position (the rest of the verts, excluding the rotated area) to get the final output displacement.
But the rotated mesh is bent. I need it to be stiff as in the whole part rotated with weight=1 except for the very pivoting vertex.
I can get it as described using a weight=1 based rotation, but the pivot point becomes the center of the mesh, not the desired point.
How can I do this correctly?
Been at it for days, please help :')
I started using Unity about a month ago, and this is one of the first issues I faced.
The node you are using will always transform the vertices around the origin.
I think you have two options available:
Translate the vertices by the offset of where you want to rotate the wings. This would require storing the pivot point of the wings in the mesh somehow - This could done by utilizing a spare UV channel, or by using the vertex color channel.
Use bones and paint the weights in your chosen 3D package. This way, you can record the animation, and use Unity's skinned mesh shader to render it.
Hope that helps.
Try this:
I've used the UV ranges from your example applied to a sphere of unit size. The spheres original pivot is in the centre, and its adjusted pivot is shifted 0.5 on the Y axis.
The only variable the shader doesn't know, is the adjusted pivot position; so I pass this through the material.
I've not implemented your weight in the graph, as I just wanted to show you the process. You can easily plug that in.
The color output is just being used for debug purposes.
The first image is with the default object pivot.
The second image is with the adjusted pivot.
The final image is the graph. (Note the logic group is driving the vertex rotation based on the UV mask).

transform a sector image to rectangle image in matlab

I am currently working the image to transform the sector part in the image to a rectangle shape.
I tried some ways but don't work well.
Any ideas on how to transform?
Create a destination image the height of which is the difference in the radii, and the width is the length of the perimeter at middle radius (this ensures square pixels along the middle arc).
Scan this image and for every pixel convert the coordinates (angle, radius) from Cartesian to polar, with a shift to the ROI center. This will give you the corresponding pixel in the source image, which you copy to the destination. Make sure to scale the angle and radius to match the destination image limits to the ROI edges.
As the source coordinates won't be integer, truncating and merely copying the source pixel achieves so-called nearest-neighbor resampling, which features visible artifacts. You can smoothen them by considering four neighboring pixels and interpolating bilinearly between them by means of the fractional parts of the coordinates.
You can even go for bicubic interpolation, using sixteen neighbors. But from my experience, the gain in quality is not so visible.

Smoothing algorithm, 2.5D

The picture below shows a triangular surface mesh. Its vertices are exactly on the surface of the original 3D object but the straight edges and faces have of course some geometric error where the original surface bends and I need some algorithm to estimate the smooth original surface.
Details: I have a height field of (a projectable part of) this surface (a 2.5D triangulation where each x,y pair has a unique height z) and I need to compute the height z of arbitrary x,y pairs. For example the z-value of the point in the image where the cursor points to.
If it was a 2D problem, I would use cubic splines but for surfaces I'm not sure what is the best solution.
As commented by #Darren what you need are patches.
It can be bi-linear patches or bi-quadratic or Coon's patches or other.
I have found no much reference doing a quick search but this links:
provide an overview: http://www.cs.cornell.edu/Courses/cs4620/2013fa/lectures/17surfaces.pdf
while this is more technical: https://www.doc.ic.ac.uk/~dfg/graphics/graphics2010/GraphicsHandout05.pdf
The concept is that you calculate splines along the edges (height function with respect to the straight edge segment itself) and then make a blending inside the surface delimited by the edges.
The patch os responsible for the blending meaning that inside any face you have an height which is a function of the point position coordinates inside the face and the values of the spline ssegments which are defined on the edges of the same face.
As per my knowledge it is quite easy to use this approach on a quadrilateral mesh (because it becomes easy to define on which edges sequence to do the splines) while I am not sure how to apply if you are forced to go for an actual triangulation.

Changing the position of the vertices in a plane

Is it possible to change the positions of the corners of an SCNPlane? Or do I have to make a custom plane to change the positions of its vertices?
EDIT:
So i have a SCNPlane or a custom created plane, and i want to atleast print the coordinates of the vertices that the plane has.
For simple effects, you can effectively change the plane's corners by using the plane's transform matrix. You can do more complex effects with a shader modifier (see SCNShadable) or a morpher (see SCNMorpher). What effect are you trying to achieve?