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 8867681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:06:12+00:00 2026-06-14T17:06:12+00:00

I’ve got the following code to do a biliner interpolation from a matrix of

  • 0

I’ve got the following code to do a biliner interpolation from a matrix of 2D vectors, each cell has x and y values of the vector, and the function receives k and l indices telling the bottom-left nearest position in the matrix

// p[1]                     returns the interpolated values
// fieldLinePointsVerts     the raw data array of fieldNumHorizontalPoints x fieldNumVerticalPoints
//                          only fieldNumHorizontalPoints matters to determine the index to access the raw data
// k and l                  horizontal and vertical indices of the point just bellow p[0] in the raw data

void interpolate( vertex2d* p, vertex2d* fieldLinePointsVerts, int fieldNumHorizontalPoints, int k, int l ) {

    int index = (l * fieldNumHorizontalPoints + k) * 2;

    vertex2d p11;
    p11.x = fieldLinePointsVerts[index].x;
    p11.y = fieldLinePointsVerts[index].y;

    vertex2d q11;
    q11.x = fieldLinePointsVerts[index+1].x;
    q11.y = fieldLinePointsVerts[index+1].y;

    index = (l * fieldNumHorizontalPoints + k + 1) * 2;

    vertex2d q21;
    q21.x = fieldLinePointsVerts[index+1].x;
    q21.y = fieldLinePointsVerts[index+1].y;

    index = ( (l + 1) * fieldNumHorizontalPoints + k) * 2;

    vertex2d q12;
    q12.x = fieldLinePointsVerts[index+1].x;
    q12.y = fieldLinePointsVerts[index+1].y;

    index = ( (l + 1) * fieldNumHorizontalPoints + k + 1 ) * 2;

    vertex2d p22;
    p22.x = fieldLinePointsVerts[index].x;
    p22.y = fieldLinePointsVerts[index].y;

    vertex2d q22;
    q22.x = fieldLinePointsVerts[index+1].x;
    q22.y = fieldLinePointsVerts[index+1].y;

    float fx = 1.0 / (p22.x - p11.x);
    float fx1 = (p22.x - p[0].x) * fx;
    float fx2 = (p[0].x - p11.x) * fx;

    vertex2d r1;
    r1.x = fx1 * q11.x + fx2 * q21.x;
    r1.y = fx1 * q11.y + fx2 * q21.y;

    vertex2d r2;
    r2.x = fx1 * q12.x + fx2 * q22.x;
    r2.y = fx1 * q12.y + fx2 * q22.y;

    float fy = 1.0 / (p22.y - p11.y);
    float fy1 = (p22.y - p[0].y) * fy;
    float fy2 = (p[0].y - p11.y) * fy; 

    p[1].x = fy1 * r1.x + fy2 * r2.x;
    p[1].y = fy1 * r1.y + fy2 * r2.y;
}

Currently this code needs to be run every single frame in old iOS devices, say devices with arm6 processors

I’ve taken the numeric sub-indices from the wikipedia’s equations http://en.wikipedia.org/wiki/Bilinear_interpolation

I’d accreciate any comments on optimization for performance, even plain asm code

  • 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-14T17:06:12+00:00Added an answer on June 14, 2026 at 5:06 pm

    This code should not be causing your slowdown if it’s only run once per frame. However, if it’s run multiple times per frame, it easily could be.

    I’d run your app with a profiler to see where the true performance problem lies.

    There is some room for optimization here: a) Certain index calculations could be factored out and re-used in subsequent calculations), b) You could dereference your fieldLinePointsVerts array to a pointer once and re-use that, instead of indexing it twice per index…

    but in general those things won’t help a great deal, unless this function is being called many, many times per frame. In which case every little thing will help.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.