Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7919817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:59:24+00:00 2026-06-03T15:59:24+00:00

I’m currently making an application which draws out a certain network of signs to

  • 0

I’m currently making an application which draws out a certain network of signs to the screen (on a CGContextRef). So far everything is going great, but now i’m finding myself in the situation that i can’t solve this problem:

I’m trying to draw an object dynamically knowing only the line its on (have the start and ending point’s x and y coordinates). With these i found the middle of the line, this is where the symbol should be drawn. With this information i found the angle of the line (with the top as 0). This is the information i have right now:

CGPoint firstLocation;
CGPoint secondLocation;
CGPoint middleLocation;

double x1 = firstLocation.x;
double y1 = firstLocation.y;
double x2 = middleLocation.x;
double y2 = middleLocation.y;

float a = (atan2(y2-y1, x2-x1) * (180/M_PI)) - 90;

I looked at using some transform function (like CGAffineTransform) on a CGRect, but this doesn’t seem to work as i need to rotate the rect around it’s center and a CGRect would only rotate around it’s origin.

I want to create the following symbols with the above information:

Image

Any help is appreciated, and if you need any more information please tell me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:59:27+00:00Added an answer on June 3, 2026 at 3:59 pm

    In my app I do something similar. I have a path that I add a transform to before drawing. The transform shifts the path to the midpoint, rotates it, and shifts it back:

    // Rotate the path such that it points to the end coordinate
    CGAffineTransform t = CGAffineTransformTranslate(
      CGAffineTransformRotate(
        CGAffineTransformMakeTranslation(middleLocation.x, middleLocation.y), 
        -a), 
      -middleLocation.x, -middleLocation.y);
    CGMutablePathRef path = CGPathCreateMutable();
    CGPoint points[8] = { ... these are the 8 points in my path ... };
    CGPathAddLines(path, &t, points, 8);
    

    You don’t have to use CGPathAddLines, that was just the easiest way for me to construct the path. All of the CGPathAdd... functions can take a transform.

    If you’re not using CGPath, you could do a similar transform in the context itself by doing CGContextTranslateCTM and CGContextRotateCTM.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.