trigonometry

Skew, size and rotate a rectangle to fit triangle perfectly

廉价感情. 提交于 2019-12-07 19:09:54
问题 I'm trying to make half of a rectangle - devided diagonally - to fit inside a triangle. Rotation works well, so does sizing of the rectangle. But once I try to skew it, it all gets messed up. Basically I want to simulate a 3D surface. That means I have to find the angle of abc, where b is the center point. And then apply this angle as a skew to the rectangle. But for some reason that doesn't work as intended. Here is a simple illustration of what I want to accomplish: You will probably

Fast sine and cosine function in java

☆樱花仙子☆ 提交于 2019-12-07 11:43:27
问题 I know about the Math.sin() and Math.cos() functions, but I'm wondering if there's a way I can create (or use an already-existing) a faster function, given that I don't care about pinpoint accuracy. I'm looking to execute a basic sin or cos calculation, and have it perform essentially as fast as possible. Would simply iterating the sigma a few times be any faster than Math.sin() ? 回答1: Since you don't care much about accuracy store it in a table that is precomputed or only computed once, this

Fast, inaccurate sin function without lookup

China☆狼群 提交于 2019-12-07 06:56:16
问题 For an ocean shader, I need a fast function that computes a very approximate value for sin(x). The only requirements are that it is periodic, and roughly resembles a sine wave. The taylor series of sin is too slow, since I'd need to compute up to the 9th power of x just to get a full period. Any suggestions? EDIT: Sorry I didn't mention, I can't use a lookup table since this is on the vertex shader. A lookup table would involve a texture sample, which on the vertex shader is slower than the

Find arc's mid-point given start, end, and center (of circle) points

强颜欢笑 提交于 2019-12-07 06:21:09
问题 I'm looking for some help on how to find an arc's mid-point. I have the start and end points, center of circle, and radius. I've searched everywhere online and cannot find an answer that I can convert into code anywhere. If anyone has any ideas, please let me know. The following picture is what I'm trying to find (assume that the center of the circle is already found). 回答1: Atan2() of the mean of x1,x2 and the mean of y1,y2 gives you the angle to the mid point. The mid point at the arc is

Cosine in floating point

最后都变了- 提交于 2019-12-07 03:41:55
问题 I am trying to implement the cosine and sine functions in floating point (but I have no floating point hardware). Since my processor has no floating-point hardware, nor instructions, I have already implemented algorithms for floating point multiplication, division, addition, subtraction, and square root. So those are the tools I have available to me to implement cosine and sine. I was considering using the CORDIC method, at this site However, I implemented division and square root using

How to get width and height of the bounding box of a rotated rectangle [duplicate]

泪湿孤枕 提交于 2019-12-06 15:23:06
This question already has answers here : Closed 7 years ago . Possible Duplicate: Calculate Bounding box coordinates from a rotated rectangle, Picture inside AABB of rotated sprite? I have a rectangle with a width of w and height of h. I rotate the rectangle r degrees(originating at its center point). How can I determine the width(w2) and height(h2) of the bounding box after the rotation. 来源: https://stackoverflow.com/questions/10177308/how-to-get-width-and-height-of-the-bounding-box-of-a-rotated-rectangle

How to bend a cylinder in three.js?

谁说胖子不能爱 提交于 2019-12-06 13:42:07
How would you arc or bend a cylinder type geometry (that has distortion) in three.js? Id like to specify these parameters: Bend Start - at what percent of the cylinder's height the bend starts Bend End - at what percent of the cylinder's height the bend ends Angle - how strong the bend is I'll be controlling them with sliders. My cylinder shape is created from an extrusion of a bezier curve that the user draws (extension of geometry class in three.js). I'd also like to be able to layer several bend effects on top of each other. So a bend could affect the first part, then a second bend could

SceneKit physics add velocity in local space

两盒软妹~` 提交于 2019-12-06 11:34:36
I am trying to manipulate the player node using physicsBody.velocity by adding or subtracting velocity to the axis for different directions. The problem is that I'm having trouble finding the method for applying that to local space or at least applying the velocity in relation to the direction the object is facing. In other words, it works fine if I have not rotated the object's node. If I do it will still add the velocity to the unrotated space. I know there is a way to add velocity to the current SCNVector3, but I cannot figure it out. if isZThrustPositive { if let velocity = self

Find angle of point on circle

拜拜、爱过 提交于 2019-12-06 10:37:54
Imagine I have drawn a circle with center coordinates (cx,cy) on the screen and a random point (A) is selected on the circle. By having the the coordinates of point A, I need to find the angle of (a). Update: I have tried using the following formula: Math.toDegrees(Math.asin(((x - cx) / radius).toDouble())) which is actually the reverse of (the circle is created by feeding angles to this one): x = radius * Math.sin(Math.toRadians(angle.toDouble())) + cx y = radius * Math.cos(Math.toRadians(angle.toDouble())) + cy But since the y coordinate is not present in the formula the answer could be

How to create Java GUI program for complex mathematical equations

ε祈祈猫儿з 提交于 2019-12-06 08:40:56
I am going through Java AWT & Swings and came to know on how to create the basic GUI elements and I was able to work on some programs with it. But when I am trying to understand how to create Graphs for some complex mathematical equations then I was not able to find some documentation or any examples. For example, in this post - How to solve the trigonometric equation cos(πθ/β)−cos(2πθ/β)=0? the user has given some complex equation and also shown how the graphs looks like. But how can we write a Java program for this equation that generates the graph GUI as output? Can someone please point me