Project 3D point to 2D screen coordinate

Project 3D point to 2D screen coordinate

By : user2953787
Date : November 21 2020, 01:01 AM
I hope this helps . I'm trying to project a few 3d points to screen coordinates to determine whether a touch occurs in roughly the same area. It should be noted that I'm doing this in Kivy, which is Python and OpenGL. I've seen questions like this, but I still don't have a solution. I've tried the following, but the numbers are not close to screen co-ordinates. , The first problem is here:
code :
p = modelview*[pos[0], pos[1], pos[2], 0])
c = p[2]
a /= c
b /= c
v4.x = v3.x
v4.y = v3.y
v4.z = v3.z
v4.w = 1.0
v4.x /= v4.w
v4.y /= v4.w
v4.z /= v4.w

Share : facebook icon twitter icon
Projecting a 3D point to a 2D screen coordinate

Projecting a 3D point to a 2D screen coordinate

By : user670003
Date : March 29 2020, 07:55 AM
Does that help Since Windows coordinates are z into the screen (x cross y), I would use something like
code :
screenY = viewPort.ActualHeight * (1 - screenY);
screenY = screenY * viewPort.ActualHeight;
screenX = viewPort.ActualWidth * (screenX + 1.0) / 2.0
screenY = viewPort.ActualHeight * (1.0 - ((screenY + 1.0) / 2.0))
Convert a given point from the window’s base coordinate system to the screen coordinate system

Convert a given point from the window’s base coordinate system to the screen coordinate system

By : RiAsta
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The window maintains its own position in global screen space and the compositor knows how to put that window's image at the correct location in screen space. The context itself, however doesn't have a location.
Quartz Compositor knows where the window is positioned on the screen, but Quartz 2D doesn't know anything more than how big the area it is supposed to draw in is. It has no idea where Quartz Compositor is going to put the drawing once it is done.
How can i draw a black point on the 0,0,-1 opengl coordinate of the screen?

How can i draw a black point on the 0,0,-1 opengl coordinate of the screen?

By : user3750693
Date : March 29 2020, 07:55 AM
To fix this issue If you want to be able to draw directly in window space then the easiest thing would be to load modelview and projection temporarily with the identity matrix and draw a GL_POINT with the location that you need. So that'd be something like:
code :


// draw the point here; specifics depending on whether you
// favour VBOs, VBAs, etc

// e.g. (assuming you don't have any client state enabled
// on entry and don't care about leaving the vertex array
// enabled on exit)
GLfloat vertexLocation[] = {0.0f, 0.0f, -1.0f};

glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
glVertexPointer(3, GL_FLOAT, 0, vertexLocation);

glDrawArrays(GL_POINTS, 0, 1);

// end of example to plot a GL_POINT



// and possibly restore yourself to some other matrix mode
// if, atypically, the rest of your code doesn't assume modelview
Convert screen coordinate to UIView local point

Convert screen coordinate to UIView local point

By : Reks Stek
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Try this if you want to get screen position from position of subContent.
[subContent convertPoint:subContentLocalPoint fromView:[UIApplication sharedApplication].keyWindow];
How to calculate 3D point (World Coordinate) from 2D mouse clicked screen coordinate point in Openscenegraph?

How to calculate 3D point (World Coordinate) from 2D mouse clicked screen coordinate point in Openscenegraph?

By : ditayb
Date : March 29 2020, 07:55 AM
should help you out Under the assumption that the mouse position is normalized in the range [-1, 1] for x and y, the following code will give you 2 points in world coordinates projected from your mouse coords: nearPoint is the point in 3D lying on the camera frustum near plane, farPointon the frustum far plane.
Than you can compute a line passing by these points and intersecting that with your plane.
code :
  // compute the matrix to unproject the mouse coords (in homogeneous space)    
  osg::Matrix VP = _camera->getViewMatrix() * _camera->getProjectionMatrix();

  osg::Matrix inverseVP;

  // compute world near far
  osg::Vec3 nearPoint(mousePosition.x, mousePosition.x, -1.0f);
  osg::Vec3 farPoint(mousePosition.x, mousePosition.x, 1.0f);
  osg::Vec3 nearPointWorld = nearPoint * inverseVP;
  osg::Vec3 farPointWorld = farPoint * inverseVP;
Related Posts Related Posts :
  • Return new instance of subclass when using methods inherited from parent class in Python
  • Which function in django.contrib.auth creates the default model permissions?
  • Formatting text in tabular form with Python
  • How to determine the first day of a month in Python
  • Error while converting date to timestamp in python
  • Python string iterations
  • Is there any file number limitation when you select multiple files with wxFileDialog?
  • Errors with Matplotlib when making an executable with Py2exe (Python)
  • Django Haystack - Indexing single field
  • Go Pro Hero 3 - Streaming video over wifi
  • Appending a column in .csv with Python/Pandas
  • How to change my result directory in Robot framework using RIDE?
  • problem with using pandas to manipulate a big text file in python
  • python-magic module' object has no attribute 'open'
  • Where goes wrong for this High Pass Filter in Python?
  • Why inserting keys in order into a python dict is faster than doint it unordered
  • flann index saving in python
  • Create new instance of list or dictionary without class
  • How can I easily convert FORTRAN code to Python code (real code, not wrappers)
  • Address of lambda function in python
  • Python adding space between characters in string. Most efficient way
  • python http server, multiple simultaneous requests
  • Disguising username & password on distributed python scripts
  • Post GraphQL mutation with Python Requests
  • Why doesnt pandas create an excel file?
  • Rolling comparison between a value and a past window, with percentile/quantile
  • How to avoid repetitive code when defining a new type in python with signature verification
  • How to configure uWSGI in order to debug with pdb (--honour-stdin configuration issue)
  • In Python, how do you execute objects that are functions from a list?
  • Python- Variable Won't Subtract?
  • Processing Power In Python
  • Python 2.7.2 - Cannot import name _random or random from sys
  • Why doesn't the Python sorted function take keyword order instead of reverse?
  • Make a function redirect to other functions depending on a variable
  • get_absolute_url in django-categories
  • Monitoring non-Celery background task with New Relic in Python
  • Feature selection with LinearSVC
  • LSTM - Predicting the same constant values after a while
  • Test the length of elements in a list
  • Django: render radiobutton with 3 columns, cost column must change according to size & quantity selected
  • Python class attributes vs global variable
  • sys.stdout.writelines("hello") and sys.stdout.write("hello")
  • is ndarray faster than recarray access?
  • Python - search through directory trees, rename certain files
  • GAE: How to build a query where a string begins with a value
  • TypeError: __init__() takes at least 2 arguments (1 given)
  • Overriding and customizing "django.contrib.auth.views.login"
  • Django : Redirect to a particular page after login
  • Python search and copy files in directory
  • pretty printing numpy ndarrays using unicode characters
  • Frequent pattern mining in Python
  • How can I make a set of functions that can be used synchronously as well as asynchronously?
  • Convert one dice roll to two dice roll
  • count occourrence in a list
  • Writing an If condition to filter out the first word
  • to read file and compare column in python
  • Install python-numpy in the Virtualenv environment
  • `.select_by_visible_text()` is failed to select element?
  • Unable to send data multiple requests in a single connection — socket error
  • Pandas HDFStore unload dataframe from memory
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org