Rotate a node so it points to a specific position in SceneKit - scenekit

I have a node and I want it's peak point to a specific position (coordinates). How can I do that? So far, I have tried noting because I have no clue how can I do that. Any suggestions?

What you want to SCNConstraint, and more specifically SCNLookAtConstraint.
There are a few similar questions on StackOverflow and examples in both SceneKit WWDC demos.
Next time you ask a question here, make sure you have a specific problem, and do as much research as you can. Show you did all of that, and you won't get downvoted!
If you encounters problems with the constraints, make sure to check if it has been asked here first. Good luck!

Related

Processing and Kinect: Change speed of video according to distance from the sensor

I'm asking a question for a school project. I am trying to play a video in a loop and change its speed according to the distance from the Kinect 1414. When you are far the video plays at normal speed, which then increases as you get closer.
I tried in different ways but sometimes either the video doesn't loop or it doesn't show, I can only hear the audio. Other solutions don't let me change the speed of the video. Do you know any way to have the distance of a person affect the video?
Thanks.
Stack Overflow isn't designed for general "how do I do this" type questions like this. It's for specific "I tried X, expected Y, but got Z instead" type questions. But I'll try to help in a general sense.
You need to break your problem down into smaller pieces and then take on those pieces one at a time. For example, can you start with a very basic sketch that just displays the distance from the Kinect? Don't worry about the video yet, just display the distance on the screen.
Separately from that, can you create another sketch that just shows a video playing in a loop? Work your way up from there: can you make it so its speed is based on a hard-coded value? How about on a value like mouseX?
Get those two basic sketches working perfectly by themselves before you start thinking about combining them. Then if you get stuck on one of those steps, you can post a MCVE along with a specific question (in a new question post), and we'll go from there. Good luck.

First Lua program--formatting text, color, background

I'm brand new here, and also to Lua, so please bear with me...
I'm building an Airport in Minecraft, with my kids. I'm an overachiever and a dreamer, and at some point, my brain decided it would be a FANTASTIC idea to add in a cosmetic element that I have absolutely NO idea how to do. Smart, right?!
See, I got it in my head that I want to have display screens in our Airport that show the flight information of incoming/outgoing flights. Fast forward to my discovery of the Opencomputers mod for Minecraft, a few hours of watching tutorials on how to operate it, and thus began my search for knowledge of that which is the Lua language. Fortunately, I have a wee bit of coding experience (thanks to my college days) and I picked up the very basic of the basics. (It seems similar to C.) I've gleaned just enough to accomplish the bigger part of my goal: I've managed to write the bare bones of the program I dreamed up, and it works...for the most part. (I still need to figure out some redundancies and such...all in good time.)
But...it's so very plain, and not fancy at all. It doesn't look even remotely like what I was picturing in my head, and this simply will not do. So now I am on a quest to discover how to format the output of my program and make it look fantastic...or at least, as close as I can get it to what was in my head. I have managed to figure out how to change the gpu screen colors (foreground, background) so that is why it's blue/white. But it's not quite what I wanted, and it resets if the system is turned off. My goal is to change the format of the program output itself, not just the Opencomputers screen block. I've googled this until I'm blue in the face, and I have pored over forums and code tutorials and the like...only to fail at finding the information I need. It's possible that I've passed up the answer, simply because I'm still very new to the language, but that's another good reason for me to be here, right?
And so, I turn to you, O Great Dwellers of the Interwebs, the Keepers of Vast Programming Knowledge, for assistance. Please, pretty please, help me make my program look awesome. My kids just may think I'm the coolest Mom on the planet, and that would be more than fantastic...Not to mention we'd have one kickass airport to play around in. :)
Here's what you'll probably want to know:
First, This pic is what I want, (on the left) and what I have (on the right).
And here is the code for my program: http://pastebin.com/60nPfpB8
I apologize up front for all of the noob mistakes that my code is more than likely riddled with. I haven't figured out yet how to make the functions repeat themselves, or a good way to utilize a 24 hour clock for the "time" function. So any suggestions there would be welcome as well.
Thank you for taking the time to read, and I appreciate any help I can get with this. :)

Jump-Point searching in detail

I have been trying to implement jump-point search to my already implemented A* pathfinding code, but I don't fully understand how it works. The website here (which is all that I could find on it) doesn't really explain much about how to prune or how to determine a jump-point successor. Could anyone explain these two things in detail?
The technical details are in the research paper, which can be found on Alban Grastien's web page.
There is also a tutorial on aigamedev.com.
It appears that an improved paper will appear at ICAPS 2014, but I don't believe the papers are online yet.
If these resources are insufficient, a more directed question (what don't you understand) will be easier to answer. But, one thing important to note is that JPS scans the state space looking for obstacles. In doing so it may look at far more states than A* does. But, its time savings come from not putting most states in the OPEN list.
In addition to the original 2011 paper, I also found this site: https://zerowidth.com/2013/a-visual-explanation-of-jump-point-search.html particularly helpful, as it explains how JPS works in simple terms with diagrams, and also includes a grid where you can add/remove obstacles and visualize how JPS finds and expands jump points.

Making a deductive program

I'm thinking about writing a program that asks the user to think of an object(a physical one) and then it asks questions about the object and tries to figure out what the user was thinking. (Similar to http://20q.net)
I tried to do it in Python but figured my approach was naive and would be very inefficient. How would you guys do this?
Doing this efficiently requires a somewhat advanced method in probability called Kullback-Liebler Divergence. Applied to decision trees (which is what you want to do) it is often called Information Gain.
But don't let that stop you! Do some searches for implementation samples of decision trees and start from there. I'd write a much simpler program before you go about solving 20 Questions.
Also, take a look at http://www.20q.net/ . Click "Think in English" then "Classic 20Q". It's scary good, sometimes.
Sounds like you want to make a computerized 21 questions game. I'd do it with a tree of questions and answers.
Here is a nice stackoverflow article about implementing trees in python
How can I implement a tree in Python? Are there any built in data structures in Python like in Java?

What do you do when you encounter a tricky problem? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What do you do when you encounter a programming problem that is really hard for you to solve, and you have no idea yet?
Usually, how do you solve it at last?
NOTES:
Could someone introduce something about problem solving practice?
If I can, I leave it alone for a while. Often the solution will pop into my head when I least expect it. (If only we always had the luxury of waiting - often we don't.)
Edit: Another hugely useful thing to do is describe the problem to someone else. Even if they can't help, the very act of explaining it to someone who's unfamiliar with the problem will often clarify things in your mind. Sometimes you get straight to a solution that way, without the other person saying a word. 8-)
I just think it over when a pencil and paper.
Break it down into each part
Look at what parts I know
Research parts I don't
Put it all together
Profit
For me the trick is breaking it into manageable bits.
-- Edit
I must agree with the poster above about talking to someone else, as well. Even if you don't have anyone you can talk to, explain it to a fluffy toy, and the answer will often become obvious.
I find using a whiteboard to explain the problem to someone else very useful.
Sometimes I'll search Stack Overflow to see if anyone has encountered the same or a similar problem; if they haven't, I'll sometimes post a question about it.
The book Peopleware put it in a nice way, that despite being a different context also works here.
The manager's function, they write, is
not to make people work but to make it
possible for people to work.
In this case you are your own manager, so its up to you to make it possible for yourself to work. If its something difficult you are struggling with, then you need to listen to yourself.. what is it you need in order to get started solving it.
For me, it can be that a major class in the project has the wrong name and is inelegant. In order to solve the problem in an elegant way these needs to be fixed first, otherwise it will end out as a half baked solution.
10 cents
For many problems, writing unit tests can help. Break it down (as silky suggests) and try writing tests for the various pieces. Then write code to make the tests pass. Check out some of the literature on TDD.
Writing throwaway "spike" code is also a handy way to figure out new things.
Well, it depends on the kind of problem, whether it's something you can research. For the things you can't, often specific design problems where I have problems keeping all the factors in mind at once, I've found two methods to work well:
Get rid of all possible distractions (computer, phone, people), e.g find an empty conference room. Take along pen and paper and draw a free-form diagram of the factors involved in the problem; sometimes tables also work well. I've found that the ability to concentrate hard without distractions and the graphical representation usually enable me to find a solution.
For really hard problems, sleep over it. Maybe that's just me, but I sometimes come up with the best ideas when I think about something in that half-dazed state right before I fall asleep - and strangely, I can always remember them come morning.

Resources