Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. Help with Angle Rotations pls..

Help with Angle Rotations pls..

Scheduled Pinned Locked Moved Managed C++/CLI
helpcom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lgmanuel
    wrote on last edited by
    #1

    hi guys, am having problem with angle rotations.. i already have the formula, double fangle; double m_iAngle; m_iAngle = 45; POINT centerPt; centerPt.x = m_nCarX + 161; // which s is the x origin centerPt.y = y + 52; // which s is the y origin fangle = m_iAngle / 180. * 3.1415926; float OrX = (float)(centerPt.x - cos(fangle)*centerPt.x + sin(fangle)*centerPt.y); float OrY = (float)(centerPt.y - cos(fangle)*centerPt.y - sin(fangle)*centerPt.x); //tyre spoke dc.SelectStockObject(GRAY_BRUSH); dc.SelectObject(m_penTyreSpoke); for(int count = 0, count < 4, count++){ //spoke1 dc.MoveTo(m_nCarX + 161, y + 52); dc.LineTo(m_nCarX + 161, y + 41); } //see image here: http://h1.ripway.com/lgmanuel/Imgs/car.png[^] as you see in the image. the car's tire has only one spoke. am trying to loop the code to have 4 (four) spokes on my rim by bending the angle 90 DEGREES.. adding a 90 DEGREES on LOOP... //should look like this images bellow: http://h1.ripway.com/lgmanuel/Imgs/car-with-rim-spoke.png[^] help guys.. check the project bellow.. thanks ahead.. http://h1.ripway.com/lgmanuel/VisualCPP/GDICarSample.rar[^]

    L 1 Reply Last reply
    0
    • L lgmanuel

      hi guys, am having problem with angle rotations.. i already have the formula, double fangle; double m_iAngle; m_iAngle = 45; POINT centerPt; centerPt.x = m_nCarX + 161; // which s is the x origin centerPt.y = y + 52; // which s is the y origin fangle = m_iAngle / 180. * 3.1415926; float OrX = (float)(centerPt.x - cos(fangle)*centerPt.x + sin(fangle)*centerPt.y); float OrY = (float)(centerPt.y - cos(fangle)*centerPt.y - sin(fangle)*centerPt.x); //tyre spoke dc.SelectStockObject(GRAY_BRUSH); dc.SelectObject(m_penTyreSpoke); for(int count = 0, count < 4, count++){ //spoke1 dc.MoveTo(m_nCarX + 161, y + 52); dc.LineTo(m_nCarX + 161, y + 41); } //see image here: http://h1.ripway.com/lgmanuel/Imgs/car.png[^] as you see in the image. the car's tire has only one spoke. am trying to loop the code to have 4 (four) spokes on my rim by bending the angle 90 DEGREES.. adding a 90 DEGREES on LOOP... //should look like this images bellow: http://h1.ripway.com/lgmanuel/Imgs/car-with-rim-spoke.png[^] help guys.. check the project bellow.. thanks ahead.. http://h1.ripway.com/lgmanuel/VisualCPP/GDICarSample.rar[^]

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, 1. first of all, are you on the right forum? have you switched from native C/C++ coding to managed C++/CLI coding all of a sudden? 2. please use PRE tags to show code snippets and do show the relevant code; nobody is going to download a ZIP/RAR file to help you out. 3. if you want N spokes, your best bet is using a for loop. They are pretty good at executing the same code over and over with a slight twist; and add 90 degrees to the angle each time. 4. Stop using all those magic constants (180, 3.1415926, 161, 52, 41). Either use a function parameter, use an object property (e.g. drawing size), use an official const such as Math.Pi, or if all else fails provide an actual const yourself. You will get more readable code with fewer errors. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups