Tilting a plane (in 3D) in the direction it's moving

I have a plane following the mouse cursor, and I want it to
tilt in the direction the mouse is moving. I'm getting these
numbers with my previousMouse variables. I'm getting the angle the
plane/cursor moves in based on this previous value and the current
value. I then try to apply the sin and cos to the rotationX and
rotationY. These are same math functions I would use if I were to
have an object move in the direction of the cursor.
I've attached code, player is the plane I'm moving/tilting.
Moving up and down kinda works (rotationX), but moving left and
right (rotationY) doesn't seem to do much. With this code, the rest
position (when not moving) is also rotated. I can fix this by
changing the rotationY line to player.rotationY =
Math.cos(previousMouseAngle) * 40 - 40;, but then going right
doesn't move it at all, and moving right moves it twice. It seems
to be a problem with the cosine of the angle returned by atan2 to
be 0 both when moving right and when not moving. What's the
problem? Am I using the completely wrong functions for what I
want?

That's not the same problem I'm having, but I'll use it to
give more details (I'm looking at the code in his first post). He's
using the keyboard to rotate a square, while I'm using the mouse.
Not only that but I want to rotate the square in relation to the
position of the mouse. Here's some scenarios:
cursor to the left of square, rotationY+
cursor to the right of square, rotationY-
cursor to the top of square, rotationX-
cursor to the top left of square, rotationY+ and rotationX-
cursor to the top right of square, rotationY- and rotationX-
I haven't listed all directions but you should get the point
by now. It's also not as simple as 8 directions, since I want 360
degree freedom. This is why I was trying to use atan2. if the
cursor is at an angle of 30 degrees. I want it to rotateY+ and
rotateX-, but there would be more rotationY than rotationX. Imagine
a UFO that's tilting in the direction it moves.

Similar Messages

  • I trying to cancel the adobe illustrator CC monthly plan. I followed the direction of the web site but there's no cancel icon in the plan management page.

    I trying to cancel the adobe illustrator CC monthly plan. I followed the direction of the web site but there's no cancel icon in the plan management page. I am paying more than 30 USD for several months for what I not using.what should i do?Creative Cloud Download & Install

    Moving this discussion to the Adobe Creative Cloud forum.
    Ssy10101 if you are unable to cancel your membership then please contact our support team directly at Contact Customer Care.

  • How to change the direction of a moving object

    I am trying to make a connect four program for class, and i am trying to make it so the red check piece move down. But instead it move left n right -.-, ive tried changing the coordinates but then the piece would just spin in circle or spins out of control. Here is the code i have right now, can someone help me please =D .
    import java.awt.*;*
    *public class Circle{*
    *private int centerX, centerY, radius;*
    *private Color color;*
    *private int direction, velocity;*
    *private boolean filled;*
    *public Circle(int x, int y, int r, Color c){*
    *centerX = x;*
    *centerY = y;*
    *radius = r;*
    *color = c;*
    *direction = 0;*
    *velocity = 0;*
    *filled = false;*
    *public void draw(Graphics g){*
    *Color oldColor = g.getColor();*
    *g.setColor(color);*
    *// Translates circle's center to rectangle's origin for drawing.*
    *if (filled)*
    *g.fillOval(centerX - radius, centerY - radius, radius*  2, radius  *2);*
    *else*
    *g.drawOval(centerX - radius, centerY - radius, radius*  2, radius  *2);*
    *g.setColor(oldColor);*
    *public void fill(Graphics g){*
    *Color oldColor = g.getColor();*
    *g.setColor(color);*
    *// Translates circle's center to rectangle's origin for drawing.*
    *g.fillOval(centerX - radius, centerY - radius, radius*  2, radius  *2);*
    *g.setColor(oldColor);*
    *public boolean containsPoint(int x, int y){*
    *int xSquared = (x - centerX)*  (x - centerX);
    int ySquared = (y - centerY)  *(y - centerY);*
    *int radiusSquared = radius*  radius;
    return xSquared  +ySquared - radiusSquared <= 0;+
    +}+
    +public void move(int xAmount, int yAmount){+
    +centerX = centerX+  xAmount;
    centerY = centerY  +yAmount;+
    +}+
    +public int getRadius(){+
    +return radius;+
    +}+
    +public int getX(){+
    +return centerX;+
    +}+
    +public int getY(){+
    +return centerY;+
    +}+
    +public void setVelocity(int v){+
    +velocity = v;+
    +}+  
    +public void setDirection(int d){+
    +direction = d % 360;+
    +}+
    +public void turn(int degrees){+
    +direction = (direction+  degrees) % 360;
    // Moves the circle in the current direction using its
    // current velocity
    public void move(){
    move((int)(velocity  *Math.cos(Math.toRadians(direction))),*
    *(int)(velocity*  Math.sin(Math.toRadians(direction))));
    public void setFilled(boolean b){
    filled = b;
    import javax.swing.*;*
    *import java.awt.*;
    import java.awt.event.*;
    public class ColorPanel extends JPanel{
    private Circle circle;
    private javax.swing.Timer timer;
    public ColorPanel(Color backColor, int width, int height){
    setBackground(backColor);
    setPreferredSize(new Dimension(width, height));
    // Circle with center point (25, 100) and radius 25
    circle = new Circle(25, height / 2, 25, Color.red);
    circle.setFilled(true);
    // Aim due west to hit left boundary first
    circle.setDirection(90);
    // Move 5 pixels per unit of time
    circle.setVelocity(5);
    // Move every 5 milliseconds
    timer = new javax.swing.Timer(5, new MoveListener());
    timer.start();
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    circle.fill(g);     
    private class MoveListener implements ActionListener{
    public void actionPerformed(ActionEvent e){
    int x = circle.getX();
    int radius = circle.getRadius();
    int width = getWidth();
    // Check for boundaries and reverse direction
    // if necessary
    if (x - radius <= 0 || x + radius >= width)
    circle.turn(90);
    circle.move();
    repaint();
    }with that code my circle just spins back n forth rapidly. How can i make it so it drop to a certain location everytime i click the mouse?

    lilkenny1337 wrote:
    I am trying to make a connect four program for class, and i am trying to make it so the red check piece move down.
    How can i make it so it drop to a certain location everytime i click the mouse?Try this:
    public class ColorPanel extends JPanel {
        private Circle circle;
        private Timer timer;
        private int stepX, stepY, xM, yM;
        public ColorPanel(final Color backColor, final int width, final int height) {
            setBackground(backColor);
            setPreferredSize(new Dimension(width, height));
            // Circle with center point (25, 100) and radius 25
            circle = new Circle(25, height / 2, 25, Color.red);
            circle.setFilled(true);
            // Aim due west to hit left boundary first
            circle.setDirection(90);
            // Move 5 pixels per unit of time
            circle.setVelocity(5);
            // Move every 5 milliseconds
            final MoveListener ml = new MoveListener();
            timer = new Timer(5, ml);
            addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(final MouseEvent e) {
                    if (timer.isRunning()) {
                        return;
                    xM = e.getX();
                    yM = e.getY();
                    int xC = circle.getX();
                    int yC = circle.getY();
                    stepX = (xM - xC) / 10;
                    stepY = (yM - yC) / 10;
                    timer.start();
        @Override
        public void paintComponent(final Graphics g) {
            super.paintComponent(g);
            circle.fill(g);
        private class MoveListener implements ActionListener {
            public void actionPerformed(final ActionEvent e) {
                if ((stepX > 0 && circle.getX() >= xM)
                        || (stepX < 0 && circle.getX() <= xM)) {
                    stepX = 0;
                if ((stepY > 0 && circle.getY() >= yM)
                        || (stepY < 0 && circle.getY() <= yM)) {
                    stepY = 0;
                if (stepX == 0 && stepY == 0) {
                    timer.stop();
                    circle.setLocation(xM, yM);
    /* add this method in the class "Circle":
        public void setLocation(int xM, int yM) {
            centerX = xM;
            centerY = yM;
                } else {
                    circle.move(stepX, stepY);
                repaint();
    }

  • How to use the direct material indicator in Plan Driven Procurement?

    Dear Experts,
    How the system determine the procurement as direct material procurement in Plan driven scenario? In case of manual shopping cart, the system determines the direct material /indirect material procurement based on the check box 'Order as direct material'
    indicator.
    Now in case of plan driven procurement, where the requisition comes from ECC system, there is no way to indicate in the MM system for direct material?
    Could you please enlighten me here?
    Thanks and regards,
    Ranjan

    Hi Ranjan,
    In case of manual shopping cart, system at that point does not know whether the material procured has inventory management maintained or material valuation. Hence we need to specify option of 'Order as direct material'.
    But when requisition is created in ECC system, SAP system already is aware of direct procurement since material used will have material master / Inventory management / Material valuation / Storage location etc maintained. And the info or some indicator will be sent to front end SRM system accordingly. 
    Moreover it does not really matter for front-end SRM system to check whether it's a direct or indirect procurement since all procurement processes followed in SRM will be exactly same.
    Hope this provides some kind of understanding for your questions.
    -Ravi

  • How to use the direct bytebuffer in JNI? Accessing JDBC from C application.

    I am working on a project to access JDBC Driver within C application. The invocation JNI is used.
    To get better performance, I use the preparedStatement for dynamic sql. This need to transfer much parameter data from C to JDBC for PreparedStatement object in JVM. I think this maybe get improvements by using the new direct bytebuffer function from JDK1.4. However I cannot find an example code to get start. Could someone provide some ideas for this?
    Currently, I directly call JDBC API in C application through JNI, so there is no java codes. Only c file using JNI call.
    My understanding is to use the direct bytebuffer feature, I also need to have java codes to process the JDBC API call and then can share the same memory between Java and C. Please correct me if wrong.
    Any input is appreciated.

    tzhouxian wrote:
    thanks, jschell
    I am trying to get the best performance for the solution, using JDBC libs in a C application. So I am considering to use the direct bytebuffer in the solution to pass parameters to JDBC and get result sets from JDBC side.
    For your questions,
    1. Why don't you just write the database access in C?
    You mean to directly call JDBC API in C through JNI, right? My plan is to wrap the JDBC API by java and expose seldom interface to C native code, so reduce the JNI call between C and JAVA. If directly call the JDBC API call from C, the number of JNI call maybe more.
    No I mean what I said. In C, no java at all, why don't you write code to access the database?
    2. The database access itself is going to be slower than anything that you do in C or java.
    Exactly. I just want to find each potential points to get performance improvements for the whole solution. I also did some optimization work for the database call. The goal is to get the best performance from C application to database through JDBC libs.
    Then I suggest you profile it.
    3. Why don't you use import/export files and the database tools? This is often significantly faster with volume processing.
    Sorry, I am not very familar with some functions of JNI. Could you explain, " +Why don't you use import/export files and the database tools+"?
    Nothing to do with java, jni nor C.
    Major (or perhaps everything that is a real 'database') comes with additional tools. Amounst those tools will be command line tools capable of importing and exporting data from the database. In processing bulk data they will always be faster than anything you can do in JDBC.

  • How to rotate map to the direction I'm facing?

    Hey all. I'm coming from Nokia Maps to this Here Map app. In Nokia Maps you can have the map orientated to the direction you are facing. It worked wonderfully if you are on foot looking for an address and came in super handy. I've noticed that Here doesn't do that. Am I not seeing it, or did they not program Here with this functionality?
    Outside of that, I'm am finding out now that I finally have the US downloaded that Here is way more smoother! I used it on the plane yesterday and the map corresponded precisely to the landscape I was watching outside the window!
    Thanks in advance for any help in figuring this out.
    Solved!
    Go to Solution.

    Here Drive will orientate itself to the direction of travel once you are in navigation mode. This is not available in Here Maps.

  • ORA-26004: Tables loaded through the direct path may not be clustered

    hi ,
    I im planning to upload data to IOT table using sqlldr. but end with error.
    ORA-26004: Tables loaded through the direct path may not be clustered.
    how to resolve this. as this table going to insert high voluem data and to speed up the table quary we created IOT table.
    table create syntax:
    create CLUSTER C_HUA
    B_number number(10),
    A_number number(10),     
    ins_date date,
    account number(10),
    C_number number(10))
    SQL> CREATE TABLE HUA
    A_number number(10),
    B_number number(10),
    ins_date date,
    account number(10),
    C_number number(10)
    CLUSTER C_HUA
    B_number,
    A_number,
    ins_date,
    account,
    C_number);
    SQL> CREATE INDEX HUA_index1 on CLUSTER C_HUA;
    Pl help to resolve this.
    thanks
    ashwan

    You have to use conventional path. DIRECT=false.
    Restrictions on Using Direct Path Loads
    The following conditions must be satisfied for you to use the direct path load method:
    * Tables are not clustered.
    * Tables to be loaded do not have any active transactions pending.
    * Loading a parent table together with a child Table
    * Loading BFILE columns

  • After delete file from documents the direct link still alive.

    Hello.
    I upload a image to the style libary folder, then i publish the file and delete him BUT the direct link to the image still work.
    I try to upload anther image with the some name but when i try to browse the direct link i get to deleted file.
    If i upload a image and delete it before i publish the file I don't have this problem.
    I try to flush the blob cache with this commends:
    $webApp = Get-SPWebApplication "<WebApplicationURL>"
    [Microsoft.SharePoint.Publishing.PublishingCache]::FlushBlobCache($webApp)
    Write-Host "Flushed the BLOB cache for:" $webAppbut this doesn't work.I clear the cache on the local pc and doesn't work to..Any idea someone?Thanks!

    Hi,
    To check if there is cache issue, please access the url in another PC to see if the issue persists. You could also open style library in SharePoint designer to double confirm it.
    In addition, if you click the ellipsis of the image item, there will be a preview panel to show the picture, is it the newly upload one?
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • HT4623 I have followed the directions and my iphone is not installing the iOS 7.0.2.  My iphone is plugged into my lap top that has the most recent version of itunes.  It is a dsl connection.  Is that my problem?

    I have followed the directions and my iphone is not installing the iOS 7.0.2.  I have the most recent version of itunes on my laptop commuter.  my iphone is attached to my laptop via usb port.  The laptop uses dsl not wifi.  Is that my problem?

    Exactly what version of iTunes are you running? And DON'T say 'the latest version'... CHECK the version number. You need to be running 11.1 or higher.

  • I followed all the directions to get Norton 360 to work with Firefox 8, but nothing works. I love Firefox, but if my Norton 360 won't work with it I'll be stuck with IE, which I do not like. Please Help Me!

    I followed all the directions to get Firefox 8 to work with my Norton 360, but nothing has worked. Is there anything else I can do? I didn't know there was an issue when I first upgraded to Firefox 8 so didn't choose the Norton plug ins immediately so I uninstalled Firefox hoping to be able to do it correctly when I Downloaded it again. Unfortunately it didn't ask me any thing regarding Norton so I went to Plug ins as directed to Enable Norton 360's plug ins, but none were listed.
    What can I do now? I LOVE Firefox! If we can't make it work I'll be stuck with Internet Explorer which I do not care for at all!
    I need to have Norton Security to protect my computer. Please help me find a solution to this problem ASAP.
    Thank you,
    Susan L Woods
    [email protected]

    Hi Susie, I use Norton 360 and have the latest Firefox 8 installed is working fine for me. Firefox 8 support for [http://community.norton.com/t5/Norton-360/Firefox-8-Support-for-Norton-Toolbar/td-p/581640 Norton Toolbar] was released on Nov 8th. Install the appropriate add-ons based on the version of Norton 360 you're using (see official Norton link above). Hope this helps.

  • I am using the Adobe Acrobat Reader on a mac and I followed all the directions to copy an image but when I press paste only half of the image appears or it appears as an empty square. What can I do to fix this?

    I am using the Adobe Acrobat Reader on a mac and I followed all the directions to copy an image but when I press paste only half of the image appears or it appears as an empty square. What can I do to fix this?

    Hello,
    I would like to inform you that not all the browsers and online PDF readers support copying text from a PDF. If you have opened the PDF online, please download PDF file to your computer and then open the file in Adobe Reader.
    Please share a screenshot if the issue still persists.
    Regards,
    Nakul

  • I have a new Macbook Pro - trying to migrate files etc from my Macbook Air using a Thunderbolt Cable between the two.  I follow the directions but the two computers never "discover" each other.  WiFi connect works but 70 hours is a rough deal.

    I have a new Macbook Pro.  Trying to migrate files etc from my Macbook Air using a Thunderbolt Cable between them.
    I follow the directions but the two computers never "discover" each other - using a WiFi connection works but 70 hours is a rough deal.
    (Mac OS 10.8.2 on both computers)

    Are you trying target disk mode?
    http://support.apple.com/kb/PH10725
    Ciao

  • HT4527 I am trying to move my library and playlists to a new computer by burning to CD's. However, I followed the directions by going to File and then Library - then they said to go to burn CD(s) - I DO NOT have that option for some reason. How do I do th

    I am trying to move my library and playlists to a new computer by burning to CD's. However, I followed the directions by going to File and then Library - then they said to go to burn CD(s) - I DO NOT have that option for some reason. How do I do this? I have done the library sharing thing but I am getting rid of my primary computer and am afraid I will lose the library.

    To move an iPhoto Library to a new machine:
    Link the two Macs together: there are several ways to do this: Wireless Network,Firewire Target Disk Mode, Ethernet, or even just copy the Library to an external HD and then on to the new machine...
    But however you do choose to link the two machines...
    Simply copy the iPhoto Library from the Pictures Folder on the old Machine to the Pictures Folder on the new Machine.
    Then hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Choose Library'
    and select the Library that you moved.  That's it.
    This moves photos, events, albums, books, keywords, slideshows and everything else.
    Your first option didn't work because you imported one Library to another. Every version and thumbnail is imported like a distinct photo, you lose all your Albums, Keywords etc., the link between Original and Previews is destroyed, the non-destructive editing feature is ruined and so on. In summary: it's mess.
    Your second option didn't work because you simply referenced her library on the old machine.
    Regards
    TD

  • HT204088 The directions you provided above doesnt even work!  when I selected "Click to open your account", there is an ERROR message and takes me to no where!  when I try to access my itunes account, it says I have no history?

    The directions you provided above doesnt even work!  when I selected "Click to open your account", there is an ERROR message and takes me to no where!  when I try to access my itunes account, it says I have no history?

    You are not able to view purchase history on your iOS device.  You may only re-download previous purchases from the iOS device.
    To review your iTunes Store account's purchase history, follow the steps in this article from a computer only:
    Seeing your iTunes Store purchase history and order numbers
    http://support.apple.com/kb/HT2727

  • Business Process: Final Demand Plan Key Figure in the past for APO DP

    Hello APO process experts,
    I have a BPX question for APO DP process owners, consultants or gurus:
    1.- Have you ever seen in any SAP APO customer, that in their APO DP planning books, they chose or designed to update the Final Demand Plan key Figure in the past closed historical buckets with the Actual Sales?
    Meaning that that in the Past closed historical Buckets, Actual Sales and Final Demand Plan, look exactily the same.
    Meaning that they create a dynamic Final Demand Plan key figure so to speak, yet they did not choose to create a key figure that also keeps the Final Demand Plan as originally entered.
    2.- Would you think that doing the above, without keeping any keyfigure in the planning book that actually shows what the Final Demand Plan was in the Past, is a good practice?
         The Demand Planner could still retreive the Final Demand Plan from BI reports, yet, dynamically they could never really see it in the planning book.
    3.- Do you think the above dynamic key figure would bias the Demand Planner's behaviour to manipulate the future open Final Demand Plan buckets to enter volumes in order sum to a monthly total, independently of what were the over and underachievements in the past (since they are not really visible to him) ?
    I would really like your feedback,
    thanks in advance!
    JD Loera

    Hello Thanks for your feedback.
    I agree with your point, and I hope that i still get more feedback from other Business Process Experts.
    I am trying to build a case for my client, to challenge the decision of their initial design as this practice is going to hurt the Demand Management process, if what they intend to achieve is a true "unconstrained demand plan"
    Much appreciated
    JD Loera

Maybe you are looking for

  • Need help unloading an External .swf within another external .swf

    My main project loads an external .swf ("room") depending on which button the user clicks. Once that external .swf ("room") is loaded, the viewer chooses a ("demo") .swf to view. I need the "demo" .swf to unload once it is finished playing so that th

  • Safari still shuts down all internet...

    Safari still shuts down all internet access when browsing abcnews.com and cbsnews.com at random times. Mail stops connecting, safari just hangs... Good thing that turning off Airport then back on again trick works everytime. So if anyone is getting t

  • Duplicate cache created in CS4

    A desktop PC and a Laptop are each generating its own cache in a central folder even though the same folder is specified. If I delete the cache from either PC/Laptop files created by both systems are deleted. Configuration: Adobe Bridge CS4 Running X

  • Cascade control simulation

    Dear Sirs I am interested in developing a cascade control simulation in LabVIEW 8.2  using LabVIEW Simulation Module. I have developed a program that I have sent you. Do you tell me if the program is good implemented?. How I should tune the primary a

  • T.coce VC/2

    I believe t.code VC/2 is the standard report. But when running the report it is giving me the error message as No view can be determined for application RVKUSTA1 for user CORESD, can anybody suggest how to get it done? Correct answar must be rewarded