logo
down
shadow

Use attractor point with a vector to change size of small cubes


Use attractor point with a vector to change size of small cubes

By : HiF
Date : November 21 2020, 11:01 PM
it should still fix some issue Ok somehow I managed to answer my own question with this schema of pluggin
code :


Share : facebook icon twitter icon
Break down cubes into 8 smaller cubes recursively (when the cubes are defined by a mid point and size)

Break down cubes into 8 smaller cubes recursively (when the cubes are defined by a mid point and size)


By : Lars Werner
Date : March 29 2020, 07:55 AM
I wish this helpful for you I'm still not quite sure if this is what you want, but here is how I woud do it:
First, I would create a class representing points in 3D space:
code :
class Point3D:
    """Representation of a point in 3D space."""
    def __init__(self, x, y, z):
        self.x = x
        self.y = y
        self.z = z

    def __add__(self, other):
        """Add two points.

        >>> Point3D(1, 2, 3) + Point3D(100, 200, 300)
        Point3D(101, 202, 303)
        """
        x = self.x + other.x
        y = self.y + other.y
        z = self.z + other.z
        return Point3D(x, y, z)

    def __mul__(self, a):
        """Multiply a point with a number.

        >>> Point3D(1, 2, 3) * 2
        Point3D(2, 4, 6)
        """
        x = self.x * a
        y = self.y * a
        z = self.z * a
        return Point3D(x, y, z)

    def __rmul__(self, a):
        """Multiply a number with a point.

        >>> 2 * Point3D(1, 2, 3)
        Point3D(2, 4, 6)
        """
        return self.__mul__(a)

    def __repr__(self):
        return 'Point3D({p.x}, {p.y}, {p.z})'.format(p=self)
from __future__ import division
from itertools import product

class Cube:
    """Representation of a cube."""

    # directions to all eight corners of a cube
    DIR = [Point3D(*s) for s in product([-1, +1], repeat=3)]

    def __init__(self, center, size, depth=0):
        if not isinstance(center, Point3D):
            center = Point3D(*center)
        self.center = center
        self.size = size
        self.depth = depth

    def __repr__(self):
        return 'Cube(center={c.center}, size={c.size}, depth={c.depth})'.format(c=self)

    def _divide(self):
        """Divide into eight cubes of half the size and one level deeper."""
        c = self.center
        a = self.size/2
        d = self.depth - 1
        return [Cube(c + a/2*e, a, d) for e in Cube.DIR]

    def divide(self, target_depth=0):
        """Recursively divide down to the given depth and return a list of
        all 8^d cubes, where d is the difference between the depth of the
        cube and the target depth, or 0 if the depth of the cube is already
        equal to or less than the target depth.

        >>> c = Cube(center=(0, 0, 0), size=2, depth=1)
        >>> len(c.divide(0))
        8
        >>> len(c.divide(-1))
        64
        >>> c.divide(5)[0] is c
        True
        >>> c.divide(-1)[0].size
        0.5
        """
        if self.depth <= target_depth:
            return [self]
        smaller_cubes = self._divide()
        return [c for s in smaller_cubes for c in s.divide(target_depth)]
# minDepthLevel = 0
# grid = {}
# grid[(1.5,0,0)] = [1,2]
# not sure what this ^ 1 means

cube = Cube((1.5, 0, 0), 4, 2)
grid = {c.center: [1, c.depth] for c in cube.divide(0)}
sizeWithAttributes gives the wrong height with NSFont on a mac when the point size is very small

sizeWithAttributes gives the wrong height with NSFont on a mac when the point size is very small


By : Vasily Kalachev
Date : March 29 2020, 07:55 AM
it should still fix some issue I am working on a mac app that lets the user zoom pretty far in on the content. I need to measure the size of text that I render. When I scale the font for the zoom the point size of the font is very small (i.e. 0.001). When I use [NSString sizeWithAttributes:] to get the size of a string I get the correct width and I always get 1.0 for the height. I also have an iOS app and this rendering class is used on both iOS and Mac. On iOS when I use a UIFont with a point size of .001 I get the correct height when I call sizeWithAttributes. , I've got the same problem. The following sample code
code :
#if TARGET_OS_IOS == 0
#define UIFont NSFont
#define NSStringFromCGSize NSStringFromSize
#endif

UIFont *uiFont = [UIFont fontWithName:@"Courier" size:19];
CGSize boxSize = [@"1" sizeWithAttributes:@{NSFontAttributeName:uiFont}];
NSLog(@"boxSize %@", NSStringFromCGSize(boxSize));
CTFontRef _contentFont = CTFontCreateWithName((__bridge CFStringRef)@"Courier", 19, NULL);
CGGlyph glyphs[1];
UniChar chars[1];
chars[0] = '1';
bool rc = CTFontGetGlyphsForCharacters(_contentFont, chars, glyphs, 1);
if (rc) {
  double advance = CTFontGetAdvancesForGlyphs(_contentFont, kCTFontOrientationDefault, glyphs, NULL, 1);
  boxSize.width = advance;
  boxSize.height = CTFontGetAscent(_contentFont) + CTFontGetDescent(_contentFont);    
}
Generate small cubes on a Plane?

Generate small cubes on a Plane?


By : user2714544
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Just use the plane's y position to instantiate instead of the hit point.
code :
GameObject plane = GameObject.Find("plane");

GameObject obj = Instantiate(prefab, new Vector3(hit.point.x, plane.transform.position.y + cubesize/2, hit.point.z), Quaternion.identity) as GameObject;
How to use a vector set point with mpc inorder to give program information on how the future set point will change

How to use a vector set point with mpc inorder to give program information on how the future set point will change


By : user3327796
Date : March 29 2020, 07:55 AM
will help you The gekko CV object only uses a scalar value of an array for SP, SPHI, and SPLO so some modification is needed to have the optimizer consider future setpoint changes. A simple MPC application shows how setpoints are used in Gekko.
code :
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt  
m = GEKKO()
m.time = np.linspace(0,20,41)
p = m.MV(value=0, lb=0, ub=100) # Declare MV
p.STATUS = 1  # allow optimizer to change
p.DCOST = 0.1 # smooth MV response
p.DMAX = 10.0 # max move each cycle
v = m.CV(value=0) # Declare CV
v.STATUS = 1  # add CV to the objective
m.options.CV_TYPE = 2 # squared error
v.SP = 40     # set point
v.TR_INIT = 1 # set point trajectory
v.TAU = 5     # time constant of trajectory
m.Equation(10*v.dt() == -v + 2*p)
m.options.IMODE = 6 # control
m.solve(disp=False)
# get additional solution information
import json
with open(m.path+'//results.json') as f:
    results = json.load(f)
plt.figure()
plt.subplot(2,1,1)
plt.plot(m.time,p.value,'b-',label='MV Optimized')
plt.legend()
plt.ylabel('Input')
plt.subplot(2,1,2)
plt.plot(m.time,results['v1.tr'],'k-',label='Reference Trajectory')
plt.plot(m.time,v.value,'r--',label='CV Response')
plt.ylabel('Output')
plt.xlabel('Time')
plt.legend(loc='best')
plt.show()
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt  
m = GEKKO()
m.time = np.linspace(0,20,41)
p = m.MV(value=0, lb=0, ub=100) # Declare MV
p.STATUS = 1  # allow optimizer to change
p.DCOST = 0.1 # smooth MV response
p.DMAX = 10.0 # max move constraint
v = m.Var(value=0) 
sp = np.ones(41)*40
sp[20:] = 60
s = m.Param(value=sp)
m.Obj((s-v)**2)
m.Equation(10*v.dt() == -v + 2*p)
m.options.IMODE = 6 # control
m.solve(disp=False)
plt.figure()
plt.subplot(2,1,1)
plt.plot(m.time,p.value,'b-',label='MV Optimized')
plt.legend()
plt.ylabel('Input')
plt.subplot(2,1,2)
plt.plot(m.time,sp,'k-',label='Setpoint')
plt.plot(m.time,v.value,'r--',label='CV Response')
plt.ylabel('Output')
plt.xlabel('Time')
plt.legend(loc='best')
plt.show()
from gekko import GEKKO
import numpy as np
import matplotlib.pyplot as plt  
m = GEKKO()
m.time = np.linspace(0,20,41)
p = m.MV(value=0, lb=0, ub=100) # Declare MV
p.STATUS = 1  # allow optimizer to change
p.DCOST = 0.1 # smooth MV response
p.DMAX = 10.0 # max move constraint
v = m.Var(value=0) 
sp = np.ones(41)*40
sp[20:] = 60
s = m.Param(value=sp)
e = m.CV(value=0) # Declare CV
e.STATUS = 1  # add CV to the objective
m.options.CV_TYPE = 2 # squared error
e.SP = 0     # set point
e.TR_INIT = 1 # error trajectory
e.TAU = 5     # time constant of trajectory
m.Equation(e==s-v)
m.Equation(10*v.dt() == -v + 2*p)
m.options.IMODE = 6 # control
m.solve(disp=False)
plt.figure()
plt.subplot(2,1,1)
plt.plot(m.time,p.value,'b-',label='MV Optimized')
plt.legend()
plt.ylabel('Input')
plt.subplot(2,1,2)
plt.plot(m.time,sp,'k-',label='Setpoint')
plt.plot(m.time,v.value,'r--',label='CV Response')
plt.ylabel('Output')
plt.xlabel('Time')
plt.legend(loc='best')
plt.show()
marching cubes, very small triangles

marching cubes, very small triangles


By : hunter
Date : March 29 2020, 07:55 AM
should help you out That's normal for marching cubes. It's a know problem of the algorythm with some technical name like redundant triangles. There is a very simple adjustment for that if you need less triangles and dont mind adding a compare equals line for every vertex, the fix is to snap iso values onto the corners of the cubes if they are more than 95% closer to them. MC optimizations are very cool the best would be octree sensing of used cubes and resizing the cubes relative to the complexity or flatness of the surface at that zone. there are awesome papers on the topic.
Here is a demonstration of a fast fix just by snapping values to corners if edge intersection proximity to corner is under 5% or over 95%, tunable, can try 90% if you want.
Related Posts Related Posts :
  • Nancy register dependency with type argument
  • How to set string date in store to date textbox inside a dojo grid
  • clEnqueueNDRangeKernel' failed with error 'out of resources'
  • JavaFX : TableView inside Dialog has duplicate items
  • How to make synchronous url requests with swift 3
  • how to access source code of PolSARpro
  • ABAC with keycloak - Using Resource attributes in policy
  • backpack-for-laravel Error install backpack for Laravel 5.3
  • How can i add custom fields in moodle assignment plugin?
  • Show executed query in Microsoft SQL Server 2016
  • How to integrate Grunt with project from eclipse.
  • How to sort items from shortest to longest
  • Dapper control dates
  • The module "APT50.dll" failed to load
  • Kentico ASCX transformation page type properties
  • The expression you entered contains invalid syntax
  • Android N showing warning alert in Zbar .SO File
  • CPU usage too high while running Ruta Script
  • UITableView load ONCE all cells in background
  • pygame: how to display full-screen without cutting off edges
  • Changing Kademlia Metric - Unidirectional Property Importance
  • Yii2 redirect 404 Page not found
  • How can I emit more values after emit an error?
  • How can I integrate my Bot (created with the Bot Framework) with Spark?
  • Install4j silent updater process hangs in case of incorrect proxy settings
  • How to force view controller orientation in iOS 10?
  • sbt dependsOn, typesafe config merges application.conf
  • Global optimization of polynomial in several variables in Maple?
  • Is there a way to monitor a SQL Server service with ZABBIX?
  • Can't install cygnus-ngsi via Docker
  • API time zone representation
  • Animation of SVG doesnt work
  • How to define and invoke inline a lambda expression in Java
  • Wit.ai - When are the actions triggered?
  • TIBCO SPOTFIRE Time on y-axis (avg duration)
  • Google PubSub Emulator: How to configure logging level
  • Run script in relative path via System.cmd in elixir
  • WSO2 Identity Server: SLO redirect not working as expected
  • Windows Mobil Apps Store Define Install and Uninstall
  • Not able to detect Kurento Media Server crash
  • Flow control in pushtechnology diffusion server delaying publishing client updates
  • Geolocalization user search: Twitter API
  • Changing the filter header in Kibana?
  • Valgrind suppression and return code
  • How can I get female voice by Web Speech API in Google Chrome
  • Strategy for quick icon generation for labview?
  • STM32 internal clocks
  • OrientDB callback after record is persisted in server
  • Position of scaling points
  • Limit nested objects results in rethinkdb query
  • Outlook REST API Push Notification always send the same ResourceData
  • OBIEE Recipients can't see all other recipients of a sent email
  • Hex Encoding and Decoding
  • Why do the bindings on my Orchestration change when I install an msi?
  • Vuejs 2 + splice
  • ImageMagick - Drawing a complex image with many (lots of) squares
  • Get specific property of a model returns error: Undefined property: Illuminate\Database\Eloquent\Builder::$id
  • Installing brew on Mac 10.6 results in syntax error
  • How to create a google map from information contained in a database
  • How can I upgrade to CocoaPods 1.1 when it has been released now?
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com