Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Making a 4D sphere

Discussion in 'Scripting' started by TrevorR1227, Dec 23, 2022.

  1. TrevorR1227

    TrevorR1227

    Joined:
    Mar 10, 2021
    Posts:
    1
    I am trying to make a 4D game but there are not very many resources to help me and I cant even create a simple 4D sphere I am using this code which I got from Jelle. It brings up an error when I mention a float4 the error is

    The type or namespace name 'float4' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]csharp(CS0246)

    also it brings up an under length and the error is

    The name 'length' does not exist in the current context [Assembly-CSharp]csharp(CS0103)

    I don't know how to fix this because I am not that good at coding.

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class HyperSphere : MonoBehaviour
    {
    public float sdHyperShpere(float4 p, float s)
    {
    return length(p) - s;
    }
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
    }
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,376
    Unless you're using the Mathematics package, float4 isn't a type in Unity. You want to use Vector4.
     
    Bunny83 and ippdev like this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,489
    As @Murgilod points out, not sure where you got this code (from a shader? some random C / C++ library?) but just delete it and start from C#.

    I have no idea what a "4D Sphere" is, but if you need examples of procedural geometry creation within Unity3D, you're welcome to check out my MakeGeo project.

    I do have great examples of 3D sphere generation in there, so perhaps you could take that and add an extra "Dee" to it and be all set.

    MakeGeo is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/makegeo

    https://github.com/kurtdekker/makegeo

    https://gitlab.com/kurtdekker/makegeo

    https://sourceforge.net/p/makegeo
     
    Bunny83 likes this.
  4. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,238
    Well,simulating 4d space is not that much more difficult than 3d, however you need a projection from 4d to 3d space and than the normal 3d to 2d projection. Though to actually have the same freedom you would need a Matrix5x5 class to do translation and rotation in 4d space. You would use a homogeneous space just like in 3d.

    In 3d space we extend the space by one dimension and use a 4x4 matrix. For 4d space you would need a 5x5 homogeneous space. Since Unity doesn't provide 5d vectors or matrices, you would need to create them yourself. I once made a 5x5 matrix and Vector5 struct, however this was only for some rudimentary 4d graphics. Unfortunately I'm currently not home, so I can't access it right now.

    Though rendering 4d geometry is not that simply either since 4d has a new volume measurement (4d volume) that is one dimension higher than the normal 3d volume. In most cases you want to render a slice of the actual geometry. A single slice through a 4d sphere is a 3d sphere. So you usually have to calcualte the intersection volume / surface yourself.

    There are countless different ways how to incoperate the 4th dimension into a game. Think of games like Magic 4d cube or Miegakure. Those work and use the 4th dimension quite differently. Other games use the 4th dimension like our real world 4d space time. So the 4th axis is just time and you can travel in the time dimension but the game graphics itself is completely 3d. You can not directly render 4d.

    Creating games that include some 4d elements are quite math heavy and almost always require a lot of custom tools and math that suit your specific needs. There's no go-to solution.
     
  5. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    But wait.

    isn’t the fourth dimension just the angle I am viewing the third dimension from?


    We can move x y z and discuss our position. But when viewed that x y z is skewed to a dimension, the fourth dimension. View angle


    The third dimension in 2D is the same position as the x 1st dimension and y 2nd dimension positions. So for 3D to be differentiated from 2D the 3rd dimension needs the angle of the fourth dimension, to enable the viewing of the 3rd dimension.

    a fifth dimension; I could not speculate what this is. A fifth dimension; could probably mean does any of it be rendered or not. If fifth dimension has value render it. Or else don’t render it. All other position space and angle are handled. Position by the 1st 2nd and 3rd dimension. Angle by the 4th dimension euler quaternion, and then the fifth dimension is whether or not you run the application for any of it to exist. The fifth dimension herein is the concept of the stability of existence.
    Whereas the fourth dimension is already being used when viewing a sphere in the editor. This is coming from the Euler and rotation of your camera and scene view camera in respect of the difference of it’s current angle to the default 2D/ 3 dimensional view via Pythagoras.

    it means you can have image like that of the perspective of your eye to the 3 dimensional world. The three dimensional world is seen through your eye the fourth dimension. The brain and eye are facilitating the existence of the fourth dimension. Without which only 3 dimensions would exist. And they would never have to be discussed or defined from a different angle.

    The fourth dimension therein is the concept of discussing the dimensions from any view angle at any point of space made available by the 1st 2nd and 3rd dimensions. This is done on the x y and z 0-360 range, so the fourth dimension view angle consists of itself 3 whole dimensions in order to define the angle. These dimensions are bubbles, they wrap what could be 0 to infinite to 360* as would a math set protractor. And it is done this way because that is the result of pi.
     
    Last edited: Dec 25, 2022
  6. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    1st dimension
    X position (expedition)

    2nd dimension
    Y position (pedition)

    3rd dimension
    Z (expedition, petition,partition = position)

    4th dimension
    Euler (perspective view angle)

    5th Dimension
    Resolution ( quality of detail )

    6th Dimension
    Existence of Logic


    In true to life order
    existence of logic 1 to make the computer
    Resolution 2 the size and number of the pixels
    Position X 3 a horizontal
    Position Y 4 a vertical
    Position Z 5 a forward
    Euler 6 how to view that grid
     
    Last edited: Dec 25, 2022
  7. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,606
    CodeParade is currently developing a 4D Golf game, with many interresting devlogs about 4D in general.
    There is also a lot of opinions about what 4D even means. Some argue time is the 4th dimension. And i have no idea what AnimalMan is trying to say right now, but seemingly that opinion exists aswell, kinda proving the point :p

    Anyways, CodeParade talks from the viewpoint of having an actual fourth axis of space.
    It's a highly interresting, but needless to say very complex, topic. No offense meant, but considering you struggle with a simple type error, im not sure you should approach this yet.

     
    Last edited: Dec 25, 2022
  8. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    4BE103F9-5992-46D3-AFBD-5D781494C017.jpeg

    To make the fourth dimension I would look into red and blue 3D goggles
     
  9. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,238
    Right, 4d just means 4 dimensions. Though in pure geometry it usually refers to a 4th spatial dimension. From a mathematical point of view it doesn't make that much of a difference. The difficulty is just to imagine / envision 4 spatial dimensions since we can only "see" 2d images and can interpret them as 3d based on other cues like dual vision and more importantly time paralax (dual vision only works well for very close vision).

    Dimensions in general, when talking about linear algebra, could mean anything. I recommend the linear algebra series of 3B1B.
     
    Yoreki likes this.
  10. AnimalMan

    AnimalMan

    Joined:
    Apr 1, 2018
    Posts:
    1,164
    It’s a chaos subject for chaos theory. Geometry can’t have a fourth dimension and google is unable to show you what a geometric fourth dimension looks like. Fourth dimension is just a concept from star trek, which invented a bunch of magical concepts and scienced them to make them more convincing. I’m sure it’s possible to find a bunch of entertainment on fourth dimension but I don’t think any of that is going to teach you how to program a fourth dimension in any meaningfully geometric way. I mean in any visual way.
    Something google says it’s time. Time is the dimension. But that’s not really useful in a geometric sense.
     
  11. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    4,238
    Sorry, but literally everything you just said is wrong :) Maybe don't discuss things you don't know nothing about. Yes, we don't have a 4th spatial dimension since we live in a 3d world. Though that just shows you don't know what mathematics and geometry is about. It generalizes to any higher dimension. You can have a 10 dimensional space. That has nothing to do with startrek and not an invention of startrek. Startrek is a science fiction series which is is based on science and mathematics with the addition of fiction.

    You seem to be way too much connected to the real world. We make games here which are purely fictional works. In alot of your other posts you seem to have a similar attitude. Mathematics and geometrie is an abstract concept. Some parts have parallels in reality, most things don't.
     
    Yoreki and chemicalcrux like this.
  12. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,606
    Watch the videos i linked, he literally does just that. That a fourth spatial dimension is hard to comprehend from the perspective of a 3 dimensional being, just as a third dimension would be hard to grasp for a 2 dimensional being, is irrelevant. We can still programm stuff like that. It might even make somewhat of half a sense, if visualized right. But it doesnt have to. Since you are a 3 dimensional being. Your brain, and the whole world in fact, works with 3 dimensions. But computers can work with 4 dimensions, or 50 for all they care, just as easily as you can make a 2 dimensional game. The visualization will get harder and harder to grasp for us, but that's an entirely different story. Reality doesnt need to have a fourth spatial dimension (which is what you googled for btw), but that doesnt mean math cant deal with higher dimensions.

    Also sorry, but Bunny is right. And quite frankly, i do feel like you keep on derailing topics more and more. For the past 1100 or so posts of yours. I thought you would eventually improve, as it's fine to be wrong when you are new.. but you just keep pushing your opinions into topics, derail them with tons of images, screenshots, outright misinformation and other nonsense, and now to top it all off you are starting to get somewhat aggressive towards the people who have to correct you on being objectively wrong.
    Sorry man, but going into the future ill report such posts. Shall someone else decide if im overreacting, but it's really hard to try and help people with someone constantly talking about some .. chaos theory, startrek or pirate movies, 3d goggles and whatnot.. when the solution to the question asked has nothing to do with any of that. It doesnt matter if you dont get that, which only brings us back to not commenting on topics you dont understand (with anything but topic related questions or such).
     
    Last edited: Dec 25, 2022
    MaskedMouse and Bunny83 like this.