trigonometry

Drawing the graph of sin(x) in java

我们两清 提交于 2019-12-08 09:35:28
问题 I am currently trying to draw the graph of sin(x) in java. I am required by the instructions of my assignment to only use drawLine() as the method of drawing the graph. I can't seem to figure out how to properly set my y value though. Right now what I have is a while loop used in order to draw the line pixel by pixel, but cannot manage to get the y value to be correct. Here is what I have so far. public class GraphJComponent extends JComponent { public void paintComponent (Graphics g){ Color

How do I draw x number of circles around a central circle, starting at the top of the center circle?

£可爱£侵袭症+ 提交于 2019-12-08 09:08:31
问题 I'm trying to create a UI that has a lot of items in circles. Sometimes these circles will have related circles that should be displayed around them. I was able to cobble together something that works, here. The problem is that the outer circles start near 0 degrees, and I'd like them to start at an angle supplied by the consumer of the function/library. I was never a star at trigonometry, or geometry, so I could use a little help. As you can see in the consuming code, there is a setting:

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

自作多情 提交于 2019-12-08 08:21:24
问题 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

How to calculate Arc length dependently of start angle?

匆匆过客 提交于 2019-12-08 07:02:51
问题 I am building a road editor where one can drag predefined road segments together and combine them to a connected road. One of those segments is a right curve. The curve is drawn as SVG (using D3 arc path function) and has two handles to change the radius and the length directly within the SVG (small black circle changes length and small black square changes the radius). I use a d3 drag handler on the handles. To calculate the new central angle I do as follows: get YOffset from center point of

determine angle between two points on a circle with respect to center

╄→尐↘猪︶ㄣ 提交于 2019-12-08 06:35:44
问题 I have a Ring(width 25px) as UIView . When User selects any where on the ring, I want to Calculate the Angle between the the Points Selected on a fixed point on the circle considering the Center of Circle. I have found few examples but they are not taking center into consideration. What is the Optimum way to do this ? 回答1: You'll have to handle the code yourself (I'm a Java developer), but the simplest way to get the angle between two points on a circle (measured against its center) is to

How do I calculate the height of the bottom edge when rotating a plane on the x-axis in 3d space?

喜夏-厌秋 提交于 2019-12-08 06:29:55
问题 In my iOS app, I have a view that I'm translating on the X axis in 3D space. The anchor point for the view is in the top center. If I rotate the view M_PI degrees, it will appear to go flat. I need X pixels between the bottom of the screen and the bottom edge of the rotated view (essentially, the bottom edge's height off the ground needs to be X px). How do I calculate this percentage of M_PI? Here's an example. In this case the view is 100px high, and I need to rotate it some percentage of M

SceneKit physics add velocity in local space

ε祈祈猫儿з 提交于 2019-12-08 03:47:13
问题 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

Find angle of point on circle

徘徊边缘 提交于 2019-12-08 00:33:27
问题 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

ThreeJS oribital camera short rotation

独自空忆成欢 提交于 2019-12-07 23:06:49
问题 I have an orbital camera that orbits are a globe. There are several markers on the globe that the user can click on, and the camera will move to that point. Using TweenMax for the animation like this - TweenMax.to(currentPos, 3, { theta:targetPos.theta, phi:targetPos.phi, radius:targetPos.radius, ease:Circ.easeIn, onComplete:btnZoomComplete, onUpdateParams:["{self}"], onComplete:SataliteTweenComplete, onUpdate: function(tween) { controls.setThetaPhi(tween.target.theta, tween.target.phi, tween

Heading from Point A to Point B in 2D space?

痞子三分冷 提交于 2019-12-07 19:36:15
问题 I'm working on a project which requires me to calculate the heading from a variable point A to a variable point B in 0 - 360 degrees to let the object at point A face point B. Now, I'm unsure on how to achieve this, I googled but didn't find any good solution. How would I calculate the heading from point A to point B in 2D space in any situation? 回答1: In a language such as C or C++ you might use the atan2 function, which calculates the arctangent of y/x over four quadrants, taking the signs